algebraic-range 0.8.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.
- algebraic_range-0.8.0/LICENSE +21 -0
- algebraic_range-0.8.0/PKG-INFO +140 -0
- algebraic_range-0.8.0/README.md +109 -0
- algebraic_range-0.8.0/pyproject.toml +58 -0
- algebraic_range-0.8.0/setup.cfg +4 -0
- algebraic_range-0.8.0/src/algebraic_range/__init__.py +24 -0
- algebraic_range-0.8.0/src/algebraic_range/core.py +517 -0
- algebraic_range-0.8.0/src/algebraic_range.egg-info/PKG-INFO +140 -0
- algebraic_range-0.8.0/src/algebraic_range.egg-info/SOURCES.txt +11 -0
- algebraic_range-0.8.0/src/algebraic_range.egg-info/dependency_links.txt +1 -0
- algebraic_range-0.8.0/src/algebraic_range.egg-info/requires.txt +4 -0
- algebraic_range-0.8.0/src/algebraic_range.egg-info/top_level.txt +1 -0
- algebraic_range-0.8.0/tests/test_algebraic_range.py +544 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniele Gregori
|
|
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,140 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: algebraic-range
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: Generate ranges of algebraic numbers — a Python port of the Wolfram Language AlgebraicRange resource function.
|
|
5
|
+
Author-email: Daniele Gregori <dangregori@gmail.com>
|
|
6
|
+
Maintainer-email: Daniele Gregori <dangregori@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/Daniele-Gregori/PyPI-packages/tree/main/packages/algebraic-range
|
|
9
|
+
Project-URL: Documentation, https://resources.wolframcloud.com/FunctionRepository/resources/AlgebraicRange/
|
|
10
|
+
Project-URL: Repository, https://github.com/Daniele-Gregori/PyPI-packages/tree/main/packages/algebraic-range
|
|
11
|
+
Project-URL: Issues, https://github.com/Daniele-Gregori/PyPI-packages/issues
|
|
12
|
+
Keywords: algebra,algebraic-numbers,range,roots,symbolic-computation,number-theory
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Intended Audience :: Education
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: sympy>=1.12
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# algebraic-range
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
[](https://github.com/Daniele-Gregori/PyPI-packages/actions/workflows/algebraic-range.yml)
|
|
36
|
+
[](https://pypi.org/project/algebraic-range/)
|
|
37
|
+
[](https://pypi.org/project/algebraic-range/)
|
|
38
|
+
[](https://opensource.org/licenses/MIT)
|
|
39
|
+
|
|
40
|
+
Generate ranges of algebraic numbers.
|
|
41
|
+
|
|
42
|
+
Python port of the **Wolfram** [resource function "AlgebraicRange"](https://resources.wolframcloud.com/FunctionRepository/resources/AlgebraicRange/) resource function.
|
|
43
|
+
|
|
44
|
+
Requires [SymPy](https://www.sympy.org/) ≥ 1.12.
|
|
45
|
+
|
|
46
|
+
## Overview
|
|
47
|
+
|
|
48
|
+
`algebraic_range` creates ranges made of [algebraic numbers](https://en.wikipedia.org/wiki/Algebraic_number). This extends the basic concept of `range()` to include, besides rational numbers, also roots — always restricted to the real domain.
|
|
49
|
+
|
|
50
|
+
The first two arguments represent the bounds of the range (minimum and maximum values), while the optional third and fourth arguments (by default equal to 1 and 0) regulate the upper and lower bounds of the steps (differences between successive elements).
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
algebraic_range(x) # Sqrt[Range[1, x²]] for x ≥ 1
|
|
58
|
+
algebraic_range(x, y) # Sqrt[Range[x², y²]] for 0 ≤ x ≤ y
|
|
59
|
+
algebraic_range(x, y, s) # step upper bound s, 0 < s ≤ y
|
|
60
|
+
algebraic_range(x, y, s, d) # step lower bound d, 0 ≤ d ≤ s
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Parameters
|
|
64
|
+
|
|
65
|
+
| Parameter | Default | Description |
|
|
66
|
+
|-----------|---------|-------------|
|
|
67
|
+
| `r1` | *(required)* | Start of range (or single argument) |
|
|
68
|
+
| `r2` | `None` | End of range |
|
|
69
|
+
| `s` | `None` | Step upper bound (negative → descending) |
|
|
70
|
+
| `d` | `0` | Step lower bound |
|
|
71
|
+
| `root_order` | `2` | `int r` → orders 2..r; `[r]` → only order r; `[r1,r2,…]` → listed orders |
|
|
72
|
+
| `step_method` | `"Outer"` | `"Outer"` or `"Root"` |
|
|
73
|
+
| `farey_range` | `False` | Use Farey-sequence–based rational multipliers |
|
|
74
|
+
| `formula_complexity_threshold` | `inf` | Discard elements above this complexity |
|
|
75
|
+
| `algebraics_only` | `True` | Reject transcendental inputs |
|
|
76
|
+
|
|
77
|
+
### Options
|
|
78
|
+
|
|
79
|
+
#### `root_order`
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
# Include square and cubic roots
|
|
83
|
+
algebraic_range(2, root_order=3)
|
|
84
|
+
|
|
85
|
+
# Only cubic roots
|
|
86
|
+
algebraic_range(2, root_order=[3])
|
|
87
|
+
|
|
88
|
+
# Cubic and fifth roots
|
|
89
|
+
algebraic_range(1, Rational(3, 2), root_order=[3, 5])
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### `step_method`
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
# "Root" method: Sqrt[Range[x², y², s²]]
|
|
96
|
+
algebraic_range(0, 3, Rational(1, 3), step_method="Root")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The default `"Outer"` method uses the outer product construction. The `"Root"` method is generally a superset.
|
|
100
|
+
|
|
101
|
+
#### `farey_range`
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
algebraic_range(0, 3, Rational(1, 3), farey_range=True)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Generalises `FareyRange` by combining algebraic ranges over all Farey-sequence steps.
|
|
108
|
+
|
|
109
|
+
#### `formula_complexity_threshold`
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
# Only keep simple expressions
|
|
113
|
+
algebraic_range(4, root_order=4, formula_complexity_threshold=8)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### `algebraics_only`
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from sympy import sqrt, E
|
|
120
|
+
|
|
121
|
+
# This raises NotAlgebraicError:
|
|
122
|
+
# algebraic_range(0, 5, sqrt(E))
|
|
123
|
+
|
|
124
|
+
# Allow transcendental step:
|
|
125
|
+
algebraic_range(0, 5, sqrt(E), algebraics_only=False)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Properties
|
|
129
|
+
|
|
130
|
+
- **Extends `range()`**: `set(range(x, y+1))` ⊆ `set(algebraic_range(x, y))`
|
|
131
|
+
- **Negative reflection**: `algebraic_range(-y, -x)` = `list(reversed([-v for v in algebraic_range(x, y)]))`
|
|
132
|
+
- **All outputs are algebraic** (when `algebraics_only=True`) and real
|
|
133
|
+
- **Sorted** in ascending order (or descending for negative step)
|
|
134
|
+
- **No duplicates**
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## See also
|
|
138
|
+
|
|
139
|
+
More details and examples can be found in the documentation for the original Wolfram Language resource function [`AlgebraicRange`](https://resources.wolframcloud.com/FunctionRepository/resources/AlgebraicRange/), contributed by the same author and vetted by the Wolfram Review Team.
|
|
140
|
+
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# algebraic-range
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
[](https://github.com/Daniele-Gregori/PyPI-packages/actions/workflows/algebraic-range.yml)
|
|
5
|
+
[](https://pypi.org/project/algebraic-range/)
|
|
6
|
+
[](https://pypi.org/project/algebraic-range/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
Generate ranges of algebraic numbers.
|
|
10
|
+
|
|
11
|
+
Python port of the **Wolfram** [resource function "AlgebraicRange"](https://resources.wolframcloud.com/FunctionRepository/resources/AlgebraicRange/) resource function.
|
|
12
|
+
|
|
13
|
+
Requires [SymPy](https://www.sympy.org/) ≥ 1.12.
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
`algebraic_range` creates ranges made of [algebraic numbers](https://en.wikipedia.org/wiki/Algebraic_number). This extends the basic concept of `range()` to include, besides rational numbers, also roots — always restricted to the real domain.
|
|
18
|
+
|
|
19
|
+
The first two arguments represent the bounds of the range (minimum and maximum values), while the optional third and fourth arguments (by default equal to 1 and 0) regulate the upper and lower bounds of the steps (differences between successive elements).
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
algebraic_range(x) # Sqrt[Range[1, x²]] for x ≥ 1
|
|
27
|
+
algebraic_range(x, y) # Sqrt[Range[x², y²]] for 0 ≤ x ≤ y
|
|
28
|
+
algebraic_range(x, y, s) # step upper bound s, 0 < s ≤ y
|
|
29
|
+
algebraic_range(x, y, s, d) # step lower bound d, 0 ≤ d ≤ s
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Parameters
|
|
33
|
+
|
|
34
|
+
| Parameter | Default | Description |
|
|
35
|
+
|-----------|---------|-------------|
|
|
36
|
+
| `r1` | *(required)* | Start of range (or single argument) |
|
|
37
|
+
| `r2` | `None` | End of range |
|
|
38
|
+
| `s` | `None` | Step upper bound (negative → descending) |
|
|
39
|
+
| `d` | `0` | Step lower bound |
|
|
40
|
+
| `root_order` | `2` | `int r` → orders 2..r; `[r]` → only order r; `[r1,r2,…]` → listed orders |
|
|
41
|
+
| `step_method` | `"Outer"` | `"Outer"` or `"Root"` |
|
|
42
|
+
| `farey_range` | `False` | Use Farey-sequence–based rational multipliers |
|
|
43
|
+
| `formula_complexity_threshold` | `inf` | Discard elements above this complexity |
|
|
44
|
+
| `algebraics_only` | `True` | Reject transcendental inputs |
|
|
45
|
+
|
|
46
|
+
### Options
|
|
47
|
+
|
|
48
|
+
#### `root_order`
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
# Include square and cubic roots
|
|
52
|
+
algebraic_range(2, root_order=3)
|
|
53
|
+
|
|
54
|
+
# Only cubic roots
|
|
55
|
+
algebraic_range(2, root_order=[3])
|
|
56
|
+
|
|
57
|
+
# Cubic and fifth roots
|
|
58
|
+
algebraic_range(1, Rational(3, 2), root_order=[3, 5])
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### `step_method`
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
# "Root" method: Sqrt[Range[x², y², s²]]
|
|
65
|
+
algebraic_range(0, 3, Rational(1, 3), step_method="Root")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The default `"Outer"` method uses the outer product construction. The `"Root"` method is generally a superset.
|
|
69
|
+
|
|
70
|
+
#### `farey_range`
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
algebraic_range(0, 3, Rational(1, 3), farey_range=True)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Generalises `FareyRange` by combining algebraic ranges over all Farey-sequence steps.
|
|
77
|
+
|
|
78
|
+
#### `formula_complexity_threshold`
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# Only keep simple expressions
|
|
82
|
+
algebraic_range(4, root_order=4, formula_complexity_threshold=8)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### `algebraics_only`
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from sympy import sqrt, E
|
|
89
|
+
|
|
90
|
+
# This raises NotAlgebraicError:
|
|
91
|
+
# algebraic_range(0, 5, sqrt(E))
|
|
92
|
+
|
|
93
|
+
# Allow transcendental step:
|
|
94
|
+
algebraic_range(0, 5, sqrt(E), algebraics_only=False)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Properties
|
|
98
|
+
|
|
99
|
+
- **Extends `range()`**: `set(range(x, y+1))` ⊆ `set(algebraic_range(x, y))`
|
|
100
|
+
- **Negative reflection**: `algebraic_range(-y, -x)` = `list(reversed([-v for v in algebraic_range(x, y)]))`
|
|
101
|
+
- **All outputs are algebraic** (when `algebraics_only=True`) and real
|
|
102
|
+
- **Sorted** in ascending order (or descending for negative step)
|
|
103
|
+
- **No duplicates**
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## See also
|
|
107
|
+
|
|
108
|
+
More details and examples can be found in the documentation for the original Wolfram Language resource function [`AlgebraicRange`](https://resources.wolframcloud.com/FunctionRepository/resources/AlgebraicRange/), contributed by the same author and vetted by the Wolfram Review Team.
|
|
109
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "algebraic-range"
|
|
7
|
+
version = "0.8.0"
|
|
8
|
+
description = "Generate ranges of algebraic numbers — a Python port of the Wolfram Language AlgebraicRange resource function."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Daniele Gregori", email = "dangregori@gmail.com" },
|
|
14
|
+
]
|
|
15
|
+
maintainers = [
|
|
16
|
+
{ name = "Daniele Gregori", email = "dangregori@gmail.com" },
|
|
17
|
+
]
|
|
18
|
+
keywords = [
|
|
19
|
+
"algebra",
|
|
20
|
+
"algebraic-numbers",
|
|
21
|
+
"range",
|
|
22
|
+
"roots",
|
|
23
|
+
"symbolic-computation",
|
|
24
|
+
"number-theory",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Intended Audience :: Science/Research",
|
|
29
|
+
"Intended Audience :: Education",
|
|
30
|
+
"Operating System :: OS Independent",
|
|
31
|
+
"Programming Language :: Python :: 3",
|
|
32
|
+
"Programming Language :: Python :: 3.9",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Programming Language :: Python :: 3.13",
|
|
37
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
38
|
+
]
|
|
39
|
+
dependencies = [
|
|
40
|
+
"sympy>=1.12",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest>=7.0",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://github.com/Daniele-Gregori/PyPI-packages/tree/main/packages/algebraic-range"
|
|
50
|
+
Documentation = "https://resources.wolframcloud.com/FunctionRepository/resources/AlgebraicRange/"
|
|
51
|
+
Repository = "https://github.com/Daniele-Gregori/PyPI-packages/tree/main/packages/algebraic-range"
|
|
52
|
+
Issues = "https://github.com/Daniele-Gregori/PyPI-packages/issues"
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.packages.find]
|
|
55
|
+
where = ["src"]
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
algebraic-range — Generate ranges of algebraic numbers.
|
|
3
|
+
|
|
4
|
+
A Python port of the Wolfram Language ResourceFunction ``AlgebraicRange``.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from algebraic_range.core import (
|
|
8
|
+
algebraic_range,
|
|
9
|
+
formula_complexity,
|
|
10
|
+
AlgebraicRangeError,
|
|
11
|
+
NotRealError,
|
|
12
|
+
NotAlgebraicError,
|
|
13
|
+
StepBoundError,
|
|
14
|
+
__version__,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"algebraic_range",
|
|
19
|
+
"formula_complexity",
|
|
20
|
+
"AlgebraicRangeError",
|
|
21
|
+
"NotRealError",
|
|
22
|
+
"NotAlgebraicError",
|
|
23
|
+
"StepBoundError",
|
|
24
|
+
]
|