numclassify 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- numclassify-0.1.0/.github/workflows/ci.yml +37 -0
- numclassify-0.1.0/.github/workflows/publish.yml +35 -0
- numclassify-0.1.0/CHANGELOG.txt +92 -0
- numclassify-0.1.0/LICENSE +21 -0
- numclassify-0.1.0/PKG-INFO +220 -0
- numclassify-0.1.0/README.md +194 -0
- numclassify-0.1.0/numclassify/__init__.py +63 -0
- numclassify-0.1.0/numclassify/__main__.py +4 -0
- numclassify-0.1.0/numclassify/_core/__init__.py +0 -0
- numclassify-0.1.0/numclassify/_core/combinatorial.py +392 -0
- numclassify-0.1.0/numclassify/_core/digital.py +403 -0
- numclassify-0.1.0/numclassify/_core/divisors.py +756 -0
- numclassify-0.1.0/numclassify/_core/figurate.py +357 -0
- numclassify-0.1.0/numclassify/_core/number_theory.py +533 -0
- numclassify-0.1.0/numclassify/_core/powers.py +349 -0
- numclassify-0.1.0/numclassify/_core/primes.py +2100 -0
- numclassify-0.1.0/numclassify/_core/recreational.py +245 -0
- numclassify-0.1.0/numclassify/_core/sequences.py +488 -0
- numclassify-0.1.0/numclassify/_registry.py +417 -0
- numclassify-0.1.0/numclassify/cli.py +525 -0
- numclassify-0.1.0/pyproject.toml +35 -0
- numclassify-0.1.0/tests/test_registry.py +348 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
pip install pytest hatchling
|
|
28
|
+
pip install -e .
|
|
29
|
+
|
|
30
|
+
- name: Run tests
|
|
31
|
+
run: python -m pytest tests/ -v
|
|
32
|
+
|
|
33
|
+
- name: Test CLI
|
|
34
|
+
run: |
|
|
35
|
+
numclassify check 153
|
|
36
|
+
numclassify find prime --limit 5
|
|
37
|
+
numclassify info armstrong
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.11"
|
|
21
|
+
|
|
22
|
+
- name: Build
|
|
23
|
+
run: |
|
|
24
|
+
pip install hatchling build
|
|
25
|
+
python -m build
|
|
26
|
+
|
|
27
|
+
- name: Publish to PyPI
|
|
28
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
29
|
+
# Uses OIDC trusted publishing — no API token needed.
|
|
30
|
+
# Before this workflow can run, go to pypi.org → Your account →
|
|
31
|
+
# Publishing → Add a new publisher, and fill in:
|
|
32
|
+
# GitHub owner: aratrikghosh2011-tech
|
|
33
|
+
# Repository: numclassify
|
|
34
|
+
# Workflow name: publish.yml
|
|
35
|
+
# Environment: pypi
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to numclassify will be documented here.
|
|
4
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
5
|
+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-04-18
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Complete package with `@register` decorator plugin architecture — any function
|
|
14
|
+
decorated with `@register` is automatically available via `get_all_properties`,
|
|
15
|
+
`get_true_properties`, the CLI, and all search utilities
|
|
16
|
+
- **3000+ number types** across 10 categories, all zero-dependency pure Python
|
|
17
|
+
|
|
18
|
+
#### Figurate engine
|
|
19
|
+
- Auto-registers 998 polygonal types (triangular through chiliagonal)
|
|
20
|
+
- Auto-registers 998 centered polygonal types (centered triangular through centered chiliagonal)
|
|
21
|
+
- Single parametric generator — adding a new figurate family is one line
|
|
22
|
+
|
|
23
|
+
#### Prime families (41 types)
|
|
24
|
+
- Standard prime, twin prime, cousin prime, sexy prime
|
|
25
|
+
- Mersenne prime, Mersenne number, double Mersenne prime
|
|
26
|
+
- Sophie Germain prime, safe prime, Cunningham chain member
|
|
27
|
+
- Wilson prime, Fermat prime, Wieferich prime, Wall-Sun-Sun prime
|
|
28
|
+
- Lucky prime, Fortunate prime, Primorial prime
|
|
29
|
+
- Emirp, palindromic prime, permutable prime, circular prime
|
|
30
|
+
- Chen prime, Eisenstein prime, Gaussian prime
|
|
31
|
+
- Titanic prime, gigantic prime, megaprime (digit-count based)
|
|
32
|
+
- OEIS references included in metadata for all 41 types
|
|
33
|
+
|
|
34
|
+
#### Digital invariants (10 types)
|
|
35
|
+
- Armstrong (narcissistic), Spy number, Harshad (Niven), Disarium
|
|
36
|
+
- Happy number (cycle detection), Neon number, Duck number
|
|
37
|
+
- Nude number (divisible by all its digits), Automorphic, Cyclic
|
|
38
|
+
|
|
39
|
+
#### Divisor-based (27 types)
|
|
40
|
+
- Perfect, abundant, deficient, weird, pseudoperfect
|
|
41
|
+
- Amicable, sociable (order 4, 6, 8), quasiperfect candidate
|
|
42
|
+
- Practical, semiperfect, primitive abundant
|
|
43
|
+
- Hyperperfect, superperfect, multiply perfect
|
|
44
|
+
- Unitary perfect, bi-unitary perfect, hemiperfect
|
|
45
|
+
- Sublime, sublime-adjacent, colossally abundant, highly abundant
|
|
46
|
+
|
|
47
|
+
#### Sequences (15 types)
|
|
48
|
+
- Fibonacci, Lucas, Tribonacci, Tetranacci
|
|
49
|
+
- Catalan, Bell, Motzkin, Padovan, Perrin
|
|
50
|
+
- Pell, Jacobsthal, Stern, Recaman
|
|
51
|
+
- Lazy caterer, cake number
|
|
52
|
+
|
|
53
|
+
#### Powers (13 types)
|
|
54
|
+
- Perfect square, perfect cube, perfect power (any exponent)
|
|
55
|
+
- Taxicab (Hardy-Ramanujan number), generalized taxicab
|
|
56
|
+
- Sum of two squares, sum of three squares, sum of four squares (Lagrange)
|
|
57
|
+
- Powerful number, squarefree, cubefree, k-free
|
|
58
|
+
- Achilles number
|
|
59
|
+
|
|
60
|
+
#### Number theory (14 types)
|
|
61
|
+
- Evil number, odious number (Thue-Morse based)
|
|
62
|
+
- Carmichael number, Zeisel number, Keith number
|
|
63
|
+
- Autobiographical number, self-describing number
|
|
64
|
+
- Kaprekar number, Kaprekar constant check
|
|
65
|
+
- Economical, equidigital, extravagant (prime factorization digit count)
|
|
66
|
+
- Polydivisible number, pandigital
|
|
67
|
+
|
|
68
|
+
#### Combinatorial (10 types)
|
|
69
|
+
- Factorial, primorial, subfactorial (derangements)
|
|
70
|
+
- Catalan number (also in sequences), Bell number (also in sequences)
|
|
71
|
+
- Binomial coefficient (any row), central binomial coefficient
|
|
72
|
+
- Catalan's triangle member, Narayana number, Motzkin number
|
|
73
|
+
|
|
74
|
+
#### Recreational (5 types)
|
|
75
|
+
- Palindrome, near-palindrome
|
|
76
|
+
- Bouncy number (neither increasing nor decreasing digits)
|
|
77
|
+
- Increasing digits, decreasing digits
|
|
78
|
+
|
|
79
|
+
#### CLI — 5 commands
|
|
80
|
+
- `numclassify check <n>` — all true properties of a number, with `--json` flag
|
|
81
|
+
- `numclassify find <type> --limit <k>` — first k numbers of a given type
|
|
82
|
+
- `numclassify range <lo> <hi> --filter <type>` — filter a range by type
|
|
83
|
+
- `numclassify list --category <cat>` — list all registered types in a category
|
|
84
|
+
- `numclassify info <type>` — name, description, OEIS ref, examples
|
|
85
|
+
|
|
86
|
+
#### Infrastructure
|
|
87
|
+
- Zero external dependencies; stdlib only
|
|
88
|
+
- Python 3.8–3.13 compatible (tested in CI matrix)
|
|
89
|
+
- 60 pytest tests, all passing
|
|
90
|
+
- GitHub Actions CI across Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
|
|
91
|
+
- PyPI publish via OIDC trusted publishing (no API token)
|
|
92
|
+
- `pyproject.toml` with Hatchling build backend
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aratrik Ghosh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: numclassify
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The most comprehensive Python library for number classification — 3000+ number types
|
|
5
|
+
Project-URL: Homepage, https://github.com/aratrikghosh2011-tech/numclassify
|
|
6
|
+
Project-URL: Repository, https://github.com/aratrikghosh2011-tech/numclassify
|
|
7
|
+
Project-URL: Issues, https://github.com/aratrikghosh2011-tech/numclassify/issues
|
|
8
|
+
Author-email: Aratrik Ghosh <aratrikghosh2011@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: armstrong,classification,figurate,mathematics,number-theory,prime
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# numclassify
|
|
28
|
+
|
|
29
|
+
> The most comprehensive Python library for number classification — 3000+ number types, zero dependencies.
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/numclassify/)
|
|
32
|
+
[](https://pypi.org/project/numclassify/)
|
|
33
|
+
[](https://github.com/aratrikghosh2011-tech/numclassify/blob/main/LICENSE)
|
|
34
|
+
[](https://github.com/aratrikghosh2011-tech/numclassify/actions/workflows/ci.yml)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Why numclassify?
|
|
39
|
+
|
|
40
|
+
Most number-theory libraries — `labmath`, `eulerlib`, `pyntlib` — answer *computational* questions: factor this, find the GCD, generate primes up to N.
|
|
41
|
+
|
|
42
|
+
`numclassify` answers a different question: **what kind of number is this?**
|
|
43
|
+
|
|
44
|
+
- `153` → Armstrong, Narcissistic, Harshad, Triangular, Abundant…
|
|
45
|
+
- `1729` → Taxicab (Hardy-Ramanujan), Zeisel, Carmichael…
|
|
46
|
+
- `28` → Perfect, Triangular, Hexagonal, Semiprime…
|
|
47
|
+
|
|
48
|
+
Over **3000 named number types**, instant lookup, no external dependencies.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install numclassify
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or clone and install in editable mode:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/aratrikghosh2011-tech/numclassify.git
|
|
62
|
+
cd numclassify
|
|
63
|
+
pip install -e .
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import numclassify as nc
|
|
72
|
+
|
|
73
|
+
# Boolean checks
|
|
74
|
+
nc.is_prime(17) # True
|
|
75
|
+
nc.is_armstrong(153) # True
|
|
76
|
+
nc.is_perfect(28) # True
|
|
77
|
+
|
|
78
|
+
# All true properties of a number
|
|
79
|
+
nc.get_true_properties(1729)
|
|
80
|
+
# ['taxicab', 'zeisel', 'carmichael', 'odd', 'composite',
|
|
81
|
+
# 'deficient', 'squarefree', 'cubefree', 'powerful_not_perfect_power']
|
|
82
|
+
|
|
83
|
+
# Search a range
|
|
84
|
+
nc.find_in_range(nc.is_armstrong, 1, 10000)
|
|
85
|
+
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474]
|
|
86
|
+
|
|
87
|
+
# Pretty-print everything about a number
|
|
88
|
+
nc.print_properties(153)
|
|
89
|
+
# ┌─────────────────────────────────────────┐
|
|
90
|
+
# │ Properties of 153 │
|
|
91
|
+
# ├─────────────────────────────────────────┤
|
|
92
|
+
# │ armstrong ✓ │
|
|
93
|
+
# │ harshad ✓ │
|
|
94
|
+
# │ triangular ✓ │
|
|
95
|
+
# │ ... │
|
|
96
|
+
# └─────────────────────────────────────────┘
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## CLI
|
|
102
|
+
|
|
103
|
+
numclassify ships with a fully-featured command-line interface.
|
|
104
|
+
|
|
105
|
+
**Check a number:**
|
|
106
|
+
```bash
|
|
107
|
+
$ numclassify check 1729
|
|
108
|
+
1729 properties:
|
|
109
|
+
taxicab ✓
|
|
110
|
+
carmichael ✓
|
|
111
|
+
zeisel ✓
|
|
112
|
+
odd ✓
|
|
113
|
+
deficient ✓
|
|
114
|
+
squarefree ✓
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**JSON output (pipe-friendly):**
|
|
118
|
+
```bash
|
|
119
|
+
$ numclassify check 153 --json
|
|
120
|
+
{"armstrong": true, "harshad": true, "triangular": true, "abundant": true, ...}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Find numbers of a type:**
|
|
124
|
+
```bash
|
|
125
|
+
$ numclassify find armstrong --limit 10
|
|
126
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 153
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Filter a range:**
|
|
130
|
+
```bash
|
|
131
|
+
$ numclassify range 1 20 --filter prime
|
|
132
|
+
2, 3, 5, 7, 11, 13, 17, 19
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**List all registered types in a category:**
|
|
136
|
+
```bash
|
|
137
|
+
$ numclassify list --category primes
|
|
138
|
+
twin_prime, mersenne_prime, sophie_germain_prime, safe_prime,
|
|
139
|
+
wilson_prime, fermat_prime, ... (41 total)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Get info about a type:**
|
|
143
|
+
```bash
|
|
144
|
+
$ numclassify info armstrong
|
|
145
|
+
Name: armstrong
|
|
146
|
+
Category: digital_invariants
|
|
147
|
+
Description: A number equal to the sum of its digits each raised to the power
|
|
148
|
+
of the number of digits. Also called narcissistic numbers.
|
|
149
|
+
OEIS: A005188
|
|
150
|
+
Examples: 1, 2, 3, 153, 370, 371, 407, 1634, 8208, 9474
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Number Categories
|
|
156
|
+
|
|
157
|
+
| Category | Count | Examples |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| Polygonal (figurate) | 998 | Triangular, Square, Pentagonal … Chiliagonal |
|
|
160
|
+
| Centered Polygonal | 998 | Centered Triangular, Centered Hexagonal … |
|
|
161
|
+
| Prime families | 41 | Twin, Mersenne, Sophie Germain, Wilson, Safe… |
|
|
162
|
+
| Digital invariants | 10 | Armstrong, Spy, Harshad, Disarium, Happy, Neon… |
|
|
163
|
+
| Divisor-based | 27 | Perfect, Abundant, Weird, Amicable, Practical… |
|
|
164
|
+
| Sequences | 15 | Fibonacci, Lucas, Catalan, Bell, Padovan… |
|
|
165
|
+
| Powers | 13 | Perfect Square, Taxicab, Sum of Two Squares… |
|
|
166
|
+
| Number theory | 14 | Evil, Carmichael, Keith, Autobiographical… |
|
|
167
|
+
| Combinatorial | 10 | Factorial, Primorial, Subfactorial, Catalan… |
|
|
168
|
+
| Recreational | 5 | Kaprekar, Automorphic, Palindrome… |
|
|
169
|
+
| **Total** | **3000+** | |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Adding Your Own Number Type
|
|
174
|
+
|
|
175
|
+
The `@register` decorator lets you plug in custom types in 6 lines:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from numclassify import register
|
|
179
|
+
|
|
180
|
+
@register(name="my_type", category="custom")
|
|
181
|
+
def is_my_type(n: int) -> bool:
|
|
182
|
+
return n > 0 and n % 7 == 0 and str(n)[0] == "4"
|
|
183
|
+
|
|
184
|
+
# Now works everywhere
|
|
185
|
+
import numclassify as nc
|
|
186
|
+
nc.is_my_type(49) # False (doesn't start with 4)
|
|
187
|
+
nc.is_my_type(42) # True
|
|
188
|
+
nc.get_true_properties(42) # [..., 'my_type', ...]
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## API Reference
|
|
194
|
+
|
|
195
|
+
| Function | Description |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `is_prime(n)` | Returns `True` if `n` is a standard prime |
|
|
198
|
+
| `is_armstrong(n)` | Returns `True` if `n` is a narcissistic/Armstrong number |
|
|
199
|
+
| `get_all_properties(n)` | Dict of every registered type → `True`/`False` |
|
|
200
|
+
| `get_true_properties(n)` | List of only the properties that are `True` |
|
|
201
|
+
| `print_properties(n)` | Pretty-prints a formatted property table to stdout |
|
|
202
|
+
| `find_in_range(fn, lo, hi)` | All integers in `[lo, hi]` where `fn` returns `True` |
|
|
203
|
+
| `find_all_in_range(lo, hi)` | Dict mapping every number in range to its true properties |
|
|
204
|
+
| `count_properties(n)` | Count of how many types apply to `n` |
|
|
205
|
+
| `most_special_in_range(lo, hi)` | The number in `[lo, hi]` with the most true properties |
|
|
206
|
+
|
|
207
|
+
Full API docs: [github.com/aratrikghosh2011-tech/numclassify](https://github.com/aratrikghosh2011-tech/numclassify)
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Requirements
|
|
212
|
+
|
|
213
|
+
- Python 3.8 or higher
|
|
214
|
+
- Zero external dependencies
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT © 2026 Aratrik Ghosh
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# numclassify
|
|
2
|
+
|
|
3
|
+
> The most comprehensive Python library for number classification — 3000+ number types, zero dependencies.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/numclassify/)
|
|
6
|
+
[](https://pypi.org/project/numclassify/)
|
|
7
|
+
[](https://github.com/aratrikghosh2011-tech/numclassify/blob/main/LICENSE)
|
|
8
|
+
[](https://github.com/aratrikghosh2011-tech/numclassify/actions/workflows/ci.yml)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Why numclassify?
|
|
13
|
+
|
|
14
|
+
Most number-theory libraries — `labmath`, `eulerlib`, `pyntlib` — answer *computational* questions: factor this, find the GCD, generate primes up to N.
|
|
15
|
+
|
|
16
|
+
`numclassify` answers a different question: **what kind of number is this?**
|
|
17
|
+
|
|
18
|
+
- `153` → Armstrong, Narcissistic, Harshad, Triangular, Abundant…
|
|
19
|
+
- `1729` → Taxicab (Hardy-Ramanujan), Zeisel, Carmichael…
|
|
20
|
+
- `28` → Perfect, Triangular, Hexagonal, Semiprime…
|
|
21
|
+
|
|
22
|
+
Over **3000 named number types**, instant lookup, no external dependencies.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install numclassify
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or clone and install in editable mode:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
git clone https://github.com/aratrikghosh2011-tech/numclassify.git
|
|
36
|
+
cd numclassify
|
|
37
|
+
pip install -e .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import numclassify as nc
|
|
46
|
+
|
|
47
|
+
# Boolean checks
|
|
48
|
+
nc.is_prime(17) # True
|
|
49
|
+
nc.is_armstrong(153) # True
|
|
50
|
+
nc.is_perfect(28) # True
|
|
51
|
+
|
|
52
|
+
# All true properties of a number
|
|
53
|
+
nc.get_true_properties(1729)
|
|
54
|
+
# ['taxicab', 'zeisel', 'carmichael', 'odd', 'composite',
|
|
55
|
+
# 'deficient', 'squarefree', 'cubefree', 'powerful_not_perfect_power']
|
|
56
|
+
|
|
57
|
+
# Search a range
|
|
58
|
+
nc.find_in_range(nc.is_armstrong, 1, 10000)
|
|
59
|
+
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474]
|
|
60
|
+
|
|
61
|
+
# Pretty-print everything about a number
|
|
62
|
+
nc.print_properties(153)
|
|
63
|
+
# ┌─────────────────────────────────────────┐
|
|
64
|
+
# │ Properties of 153 │
|
|
65
|
+
# ├─────────────────────────────────────────┤
|
|
66
|
+
# │ armstrong ✓ │
|
|
67
|
+
# │ harshad ✓ │
|
|
68
|
+
# │ triangular ✓ │
|
|
69
|
+
# │ ... │
|
|
70
|
+
# └─────────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## CLI
|
|
76
|
+
|
|
77
|
+
numclassify ships with a fully-featured command-line interface.
|
|
78
|
+
|
|
79
|
+
**Check a number:**
|
|
80
|
+
```bash
|
|
81
|
+
$ numclassify check 1729
|
|
82
|
+
1729 properties:
|
|
83
|
+
taxicab ✓
|
|
84
|
+
carmichael ✓
|
|
85
|
+
zeisel ✓
|
|
86
|
+
odd ✓
|
|
87
|
+
deficient ✓
|
|
88
|
+
squarefree ✓
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**JSON output (pipe-friendly):**
|
|
92
|
+
```bash
|
|
93
|
+
$ numclassify check 153 --json
|
|
94
|
+
{"armstrong": true, "harshad": true, "triangular": true, "abundant": true, ...}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Find numbers of a type:**
|
|
98
|
+
```bash
|
|
99
|
+
$ numclassify find armstrong --limit 10
|
|
100
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 153
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Filter a range:**
|
|
104
|
+
```bash
|
|
105
|
+
$ numclassify range 1 20 --filter prime
|
|
106
|
+
2, 3, 5, 7, 11, 13, 17, 19
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**List all registered types in a category:**
|
|
110
|
+
```bash
|
|
111
|
+
$ numclassify list --category primes
|
|
112
|
+
twin_prime, mersenne_prime, sophie_germain_prime, safe_prime,
|
|
113
|
+
wilson_prime, fermat_prime, ... (41 total)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Get info about a type:**
|
|
117
|
+
```bash
|
|
118
|
+
$ numclassify info armstrong
|
|
119
|
+
Name: armstrong
|
|
120
|
+
Category: digital_invariants
|
|
121
|
+
Description: A number equal to the sum of its digits each raised to the power
|
|
122
|
+
of the number of digits. Also called narcissistic numbers.
|
|
123
|
+
OEIS: A005188
|
|
124
|
+
Examples: 1, 2, 3, 153, 370, 371, 407, 1634, 8208, 9474
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Number Categories
|
|
130
|
+
|
|
131
|
+
| Category | Count | Examples |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| Polygonal (figurate) | 998 | Triangular, Square, Pentagonal … Chiliagonal |
|
|
134
|
+
| Centered Polygonal | 998 | Centered Triangular, Centered Hexagonal … |
|
|
135
|
+
| Prime families | 41 | Twin, Mersenne, Sophie Germain, Wilson, Safe… |
|
|
136
|
+
| Digital invariants | 10 | Armstrong, Spy, Harshad, Disarium, Happy, Neon… |
|
|
137
|
+
| Divisor-based | 27 | Perfect, Abundant, Weird, Amicable, Practical… |
|
|
138
|
+
| Sequences | 15 | Fibonacci, Lucas, Catalan, Bell, Padovan… |
|
|
139
|
+
| Powers | 13 | Perfect Square, Taxicab, Sum of Two Squares… |
|
|
140
|
+
| Number theory | 14 | Evil, Carmichael, Keith, Autobiographical… |
|
|
141
|
+
| Combinatorial | 10 | Factorial, Primorial, Subfactorial, Catalan… |
|
|
142
|
+
| Recreational | 5 | Kaprekar, Automorphic, Palindrome… |
|
|
143
|
+
| **Total** | **3000+** | |
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Adding Your Own Number Type
|
|
148
|
+
|
|
149
|
+
The `@register` decorator lets you plug in custom types in 6 lines:
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from numclassify import register
|
|
153
|
+
|
|
154
|
+
@register(name="my_type", category="custom")
|
|
155
|
+
def is_my_type(n: int) -> bool:
|
|
156
|
+
return n > 0 and n % 7 == 0 and str(n)[0] == "4"
|
|
157
|
+
|
|
158
|
+
# Now works everywhere
|
|
159
|
+
import numclassify as nc
|
|
160
|
+
nc.is_my_type(49) # False (doesn't start with 4)
|
|
161
|
+
nc.is_my_type(42) # True
|
|
162
|
+
nc.get_true_properties(42) # [..., 'my_type', ...]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## API Reference
|
|
168
|
+
|
|
169
|
+
| Function | Description |
|
|
170
|
+
|---|---|
|
|
171
|
+
| `is_prime(n)` | Returns `True` if `n` is a standard prime |
|
|
172
|
+
| `is_armstrong(n)` | Returns `True` if `n` is a narcissistic/Armstrong number |
|
|
173
|
+
| `get_all_properties(n)` | Dict of every registered type → `True`/`False` |
|
|
174
|
+
| `get_true_properties(n)` | List of only the properties that are `True` |
|
|
175
|
+
| `print_properties(n)` | Pretty-prints a formatted property table to stdout |
|
|
176
|
+
| `find_in_range(fn, lo, hi)` | All integers in `[lo, hi]` where `fn` returns `True` |
|
|
177
|
+
| `find_all_in_range(lo, hi)` | Dict mapping every number in range to its true properties |
|
|
178
|
+
| `count_properties(n)` | Count of how many types apply to `n` |
|
|
179
|
+
| `most_special_in_range(lo, hi)` | The number in `[lo, hi]` with the most true properties |
|
|
180
|
+
|
|
181
|
+
Full API docs: [github.com/aratrikghosh2011-tech/numclassify](https://github.com/aratrikghosh2011-tech/numclassify)
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Requirements
|
|
186
|
+
|
|
187
|
+
- Python 3.8 or higher
|
|
188
|
+
- Zero external dependencies
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
MIT © 2026 Aratrik Ghosh
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""
|
|
2
|
+
numclassify
|
|
3
|
+
~~~~~~~~~~~
|
|
4
|
+
The most comprehensive Python library for number classification.
|
|
5
|
+
Importing this package triggers registration of all built-in classification
|
|
6
|
+
functions via their ``@register`` decorators.
|
|
7
|
+
|
|
8
|
+
Public API
|
|
9
|
+
----------
|
|
10
|
+
.. autosummary::
|
|
11
|
+
is_prime
|
|
12
|
+
is_armstrong
|
|
13
|
+
is_perfect
|
|
14
|
+
get_all_properties
|
|
15
|
+
get_true_properties
|
|
16
|
+
print_properties
|
|
17
|
+
find_in_range
|
|
18
|
+
find_all_in_range
|
|
19
|
+
count_properties
|
|
20
|
+
most_special_in_range
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
__version__ = "0.1.0"
|
|
25
|
+
|
|
26
|
+
# --- Import all _core submodules so @register decorators fire at import time ---
|
|
27
|
+
from numclassify._core import primes # noqa: F401
|
|
28
|
+
from numclassify._core import figurate # noqa: F401
|
|
29
|
+
from numclassify._core import digital # noqa: F401
|
|
30
|
+
from numclassify._core import recreational # noqa: F401
|
|
31
|
+
from numclassify._core import divisors # noqa: F401
|
|
32
|
+
from numclassify._core import sequences # noqa: F401
|
|
33
|
+
from numclassify._core import powers # noqa: F401
|
|
34
|
+
from numclassify._core import number_theory # noqa: F401
|
|
35
|
+
from numclassify._core import combinatorial # noqa: F401
|
|
36
|
+
|
|
37
|
+
# --- Re-export key functions at top level ---
|
|
38
|
+
from numclassify._core.primes import is_prime # noqa: F401
|
|
39
|
+
from numclassify._core.digital import is_armstrong # noqa: F401
|
|
40
|
+
from numclassify._core.divisors import is_perfect # noqa: F401
|
|
41
|
+
from numclassify._registry import ( # noqa: F401
|
|
42
|
+
get_all_properties,
|
|
43
|
+
get_true_properties,
|
|
44
|
+
print_properties,
|
|
45
|
+
find_in_range,
|
|
46
|
+
find_all_in_range,
|
|
47
|
+
count_properties,
|
|
48
|
+
most_special_in_range,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
"__version__",
|
|
53
|
+
"is_prime",
|
|
54
|
+
"is_armstrong",
|
|
55
|
+
"is_perfect",
|
|
56
|
+
"get_all_properties",
|
|
57
|
+
"get_true_properties",
|
|
58
|
+
"print_properties",
|
|
59
|
+
"find_in_range",
|
|
60
|
+
"find_all_in_range",
|
|
61
|
+
"count_properties",
|
|
62
|
+
"most_special_in_range",
|
|
63
|
+
]
|
|
File without changes
|