Skip to main content

Transform-aware identifier for OEIS integer sequences

Project description

oeis-seek

CI PyPI License: MIT

Identify the OEIS sequence a list of integers belongs to - even when the raw numbers are not in OEIS but a simple transform of them is.

oeis-seek works offline against a local copy of the OEIS bulk dump. You download the dump once, then look up sequences with no network calls and no rate limits.

Install

Install the released CLI from PyPI (the package is oeis-seek; it installs a oeis-seek command):

uv tool install oeis-seek    # or: pipx install oeis-seek, or: pip install oeis-seek

Or work from a clone:

uv sync

Usage

First, download and index the OEIS dump (one time; re-run to refresh):

oeis-seek update

Then identify a sequence:

oeis-seek 0,1,1,2,3,5,8,13          # -> A000045 (Fibonacci), raw match
oeis-seek 2,6,12,20,30,42           # -> hit via first differences
echo "1 2 6 24 120" | oeis-seek     # terms from stdin
oeis-seek 2,6,12,20 --json          # machine-readable output
oeis-seek 2,6,12,20 --limit 5       # cap results (default 10)

Terms may be comma- or whitespace-separated, passed as arguments or piped on stdin. At least four terms are required by default (--min-terms lowers it).

How it works

Three ideas do the work.

The matcher (framed-substring contiguous match)

The index stores each sequence's terms as a comma-framed string, ,0,1,1,2,3,5,. A lookup frames the query the same way, ,1,2,3,5,, and asks which stored sequences contain that substring. Framing the run on both sides makes substring containment exactly the contiguous-subsequence predicate OEIS itself uses: term boundaries hold (2,3 cannot match inside 23), terms must be adjacent, and signs are respected. At ~370k sequences this resolves well under a second, so the MVP needs no inverted index.

The transforms

Before matching, oeis-seek also tries simple transforms of your input and looks each result up:

  • raw - the input as given
  • first differences - a(n+1) - a(n)
  • partial sums - running totals
  • consecutive ratios - a(n+1) / a(n) (later over earlier), used only when every ratio divides exactly, e.g. 1, 2, 6, 24 becomes 2, 3, 4
  • higher-order differences - first differences applied repeatedly (orders 2 and 3)
  • a(n) - n and a(n) / n - subtract or divide by the 0-based index (the latter integer-only)
  • absolute values - abs(a(n)), to recognize a signed sequence by magnitude

Transforms live in a registry, so adding more later is one function plus one registration.

The ranking

Every hit gets a deterministic, explainable score. Matches needing no transform rank above transformed ones, more matched terms rank higher, and sequences in OEIS's curated core set are boosted so canonical sequences outrank obscure ones that merely share a run. A run found near a sequence's opening is weak extra evidence over one buried deep inside, and ties resolve by ascending A-number so output is stable. All scoring weights live in one place, and each result tells you which transform found it and why it ranked where it did.

Development

Lint, format, and test:

uv run ruff check .
uv run ruff format .
uv run pytest

CI runs ruff and pytest on every push and pull request.

To refresh the embedded OEIS core set:

uv run python tools/generate_core_set.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oeis_seek-0.1.0.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oeis_seek-0.1.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file oeis_seek-0.1.0.tar.gz.

File metadata

  • Download URL: oeis_seek-0.1.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oeis_seek-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7df1bdfcd172019d17bbd609be30274696bd5b48555cc5c1d1087d569e9e9e25
MD5 8ef53c2070f1e07bc37f5a0d3199f001
BLAKE2b-256 b01fb424c560460a5046a9c6fbf1d4f4ef8da8b7dea0e11259bae4c23291d740

See more details on using hashes here.

File details

Details for the file oeis_seek-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oeis_seek-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oeis_seek-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb85b1d1d596b105b9692396164ca3d0f5c85bcfea2158dd30251fa1d54d550e
MD5 c466bee9a16375b77761f08a3a9ee74d
BLAKE2b-256 27b6ceadc5112980e7004a2fa7ab234ffd49217efe105a80903e6fa8113e0af7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page