foxmath 0.1.0__tar.gz → 0.1.2__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.
- {foxmath-0.1.0 → foxmath-0.1.2}/PKG-INFO +1 -1
- {foxmath-0.1.0 → foxmath-0.1.2}/pyproject.toml +4 -1
- {foxmath-0.1.0 → foxmath-0.1.2}/src/foxmath/foxmath.py +8 -3
- {foxmath-0.1.0 → foxmath-0.1.2}/src/foxmath.egg-info/PKG-INFO +1 -1
- foxmath-0.1.2/src/foxmath.egg-info/entry_points.txt +5 -0
- {foxmath-0.1.0 → foxmath-0.1.2}/tests/test_cli.py +9 -0
- foxmath-0.1.0/src/foxmath.egg-info/entry_points.txt +0 -2
- {foxmath-0.1.0 → foxmath-0.1.2}/LICENSE +0 -0
- {foxmath-0.1.0 → foxmath-0.1.2}/README.md +0 -0
- {foxmath-0.1.0 → foxmath-0.1.2}/setup.cfg +0 -0
- {foxmath-0.1.0 → foxmath-0.1.2}/src/foxmath/__init__.py +0 -0
- {foxmath-0.1.0 → foxmath-0.1.2}/src/foxmath.egg-info/SOURCES.txt +0 -0
- {foxmath-0.1.0 → foxmath-0.1.2}/src/foxmath.egg-info/dependency_links.txt +0 -0
- {foxmath-0.1.0 → foxmath-0.1.2}/src/foxmath.egg-info/top_level.txt +0 -0
- {foxmath-0.1.0 → foxmath-0.1.2}/tests/test_foxmath.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "foxmath"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "Minimalist CLI for math & cryptography exploration 🦊"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
@@ -28,3 +28,6 @@ dependencies = [] # Pure stdlib for now
|
|
|
28
28
|
|
|
29
29
|
[project.scripts]
|
|
30
30
|
foxmath = "foxmath.foxmath:main"
|
|
31
|
+
foxmath-legendre = "foxmath.foxmath:main"
|
|
32
|
+
foxmath-pi = "foxmath.foxmath:main"
|
|
33
|
+
foxmath-ecadd = "foxmath.foxmath:main"
|
|
@@ -38,6 +38,8 @@ def catalan_pi_approx(terms: int = 100) -> Decimal:
|
|
|
38
38
|
|
|
39
39
|
def ec_point_add(x1, y1, x2, y2, a, p):
|
|
40
40
|
"""Simple elliptic curve point addition over finite field y² = x³ + a x + b (mod p)"""
|
|
41
|
+
x1, y1, x2, y2 = x1 % p, y1 % p, x2 % p, y2 % p
|
|
42
|
+
|
|
41
43
|
if x1 % p == x2 % p and (y1 + y2) % p == 0:
|
|
42
44
|
raise ValueError(
|
|
43
45
|
"Result is the point at infinity (P + (-P)); this simplified "
|
|
@@ -110,17 +112,20 @@ def main():
|
|
|
110
112
|
if cmd == "legendre" or args.command == "legendre":
|
|
111
113
|
ls = legendre_symbol(args.a, args.p)
|
|
112
114
|
result.update({"command": "legendre", "a": args.a, "p": args.p, "value": ls})
|
|
113
|
-
|
|
115
|
+
if not json_output:
|
|
116
|
+
print(f"Legendre ({args.a}/{args.p}) = {ls}")
|
|
114
117
|
|
|
115
118
|
elif cmd == "pi" or args.command == "pi":
|
|
116
119
|
approx = catalan_pi_approx(args.terms)
|
|
117
120
|
result.update({"command": "pi", "terms": args.terms, "approx": str(approx)})
|
|
118
|
-
|
|
121
|
+
if not json_output:
|
|
122
|
+
print(f"π ≈ {approx} ({args.terms} terms)")
|
|
119
123
|
|
|
120
124
|
elif cmd == "ecadd" or args.command == "ecadd":
|
|
121
125
|
x3, y3 = ec_point_add(args.x1, args.y1, args.x2, args.y2, args.a, args.p)
|
|
122
126
|
result.update({"command": "ecadd", "result": (x3, y3)})
|
|
123
|
-
|
|
127
|
+
if not json_output:
|
|
128
|
+
print(f"Result point: ({x3}, {y3})")
|
|
124
129
|
|
|
125
130
|
except Exception as e:
|
|
126
131
|
print(f"Error: {e}", file=sys.stderr)
|
|
@@ -38,6 +38,15 @@ class TestJsonFlag(unittest.TestCase):
|
|
|
38
38
|
self.assertEqual(code, 0)
|
|
39
39
|
self.assertNotIn("{", out)
|
|
40
40
|
|
|
41
|
+
def test_json_output_is_pure_json_no_preamble(self):
|
|
42
|
+
# Regression check: --json used to still print the human-readable
|
|
43
|
+
# line first, breaking anything piping stdout into a JSON parser.
|
|
44
|
+
code, out, err = run("pi", "--terms", "20", "--json")
|
|
45
|
+
self.assertEqual(code, 0)
|
|
46
|
+
import json
|
|
47
|
+
parsed = json.loads(out) # raises if there's any leading text
|
|
48
|
+
self.assertEqual(parsed["command"], "pi")
|
|
49
|
+
|
|
41
50
|
|
|
42
51
|
class TestSymlinkInvocation(unittest.TestCase):
|
|
43
52
|
def setUp(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|