Skip to content

Commit 958fb3a

Browse files
committed
Fix type annotations and rational matrix construction for #1739
1 parent 6687db6 commit 958fb3a

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/jacobian/math/lattices/_lattice_operations.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _basis_int_list(lattice: IntegerLattice) -> list[list[int]]:
8888
def _require_full_row_rank(lattice: IntegerLattice, *, label: str) -> list[list[int]]:
8989
entries = _basis_int_list(lattice)
9090
rows = len(entries)
91-
if integer_rank(lattice.basis.entries) != rows:
91+
if integer_rank(entries) != rows:
9292
raise ValueError(f"{label} basis must be full row rank over QQ")
9393
return entries
9494

@@ -102,12 +102,11 @@ def _integer_matrix(matrix: list[list[int]]) -> IntegerMatrix:
102102

103103

104104
def _rational_matrix(matrix: list[list[Fraction]]) -> RationalMatrix:
105+
from jacobian._exact import CanonicalRational
106+
105107
return RationalMatrix(
106108
entries=tuple(
107-
tuple(
108-
{"num": str(frac.numerator), "den": str(frac.denominator)}
109-
for frac in row
110-
)
109+
tuple(CanonicalRational.from_fraction(frac) for frac in row)
111110
for row in matrix
112111
)
113112
)

src/jacobian/math/lattices/_lattice_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _entries_to_int(matrix: Any) -> list[list[int]]:
5656
return [[int(matrix[i, j]) for j in range(cols)] for i in range(rows)]
5757

5858

59-
def integer_rank(entries: list[list[str | int]]) -> int:
59+
def integer_rank(entries: list[list[int]]) -> int:
6060
"""Return the exact rank over ``QQ`` of an integer entry matrix."""
6161
from sympy import Matrix
6262

src/jacobian/math/lattices/_lattice_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
__all__ = ["LATTICE_STRUCTURE_OPERATIONS"]
4141

4242

43-
def _lattice(ambient: int, basis: list[list[int]]) -> dict:
43+
def _lattice(ambient: int, basis: list[list[int]]) -> dict[str, object]:
4444
"""Return a JSON-serialable IntegerLattice payload for examples."""
4545
return {
4646
"ambient_dimension": ambient,

0 commit comments

Comments
 (0)