Reorganize extended examples and minor updates - #16
Conversation
Code Review: PR #16 — Reorganize extended examples and minor updatesOverviewTwo-part PR: (1) replaces 9 ad-hoc example notebooks ( Net source changes: +170 / -211 lines (excluding notebooks). Notebooks: +5900 / -5900 — they dominate diff size but are pure noise to review. What's Good
Bugs / Correctness Issues1. return self(self.R(u) * self.E(u) * self.T(a) * self.L(b))
2. Breaking API rename without deprecation 3. 4. 5. This dead expression does nothing in either form. Either delete it or actually use 6. Determinant check in x.determinant() in parent.number_field().unit_group()replaces Style / Minor
Tests
Recommended Action
|
- random_element: use R(d) (coprime residue) instead of R(u) (a unit).
- random_element: tidy `d = 1`, `if not coprime_residue`.
- random_element: docstring lists current modes {'Lower','Upper','Unit','Lift'}
and adds structural doctests for each mode plus a Lift test with
non-trivial level_ideal.
- R(d): docstring corrected ("coprime to level_ideal", no default).
- cusps(): drop dead `#a2 = ...` line.
- coset_matrices(): fix 3-space indentation to 4 spaces.
- ExtendedHilbertPullback.__init__: remove stray double blank line.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Pushed Fixed
Not changed — needs your input
Also left untouched: the broader test-coverage gap for Couldn't run the doctests locally — sage env hit a passagemath 10.5/10.8 ABI mismatch ( |
|
@sujeetksb following up on point 2 from my fix-summary comment — could you confirm the Old behavior ( for D in divisors(N):
# ... compute reps for every divisor D, including D == N ...
for r in (N / D).residues():
if I.is_coprime(r):
# ... build a, b, c, d ...
L.append(H.create_element(a, b, c, d))
for x in L:
if x in self:
idx = L.index(x)
L[idx] = H.create_element(1, 0, 0, 1)
breakThe loop ran for every New behavior (added): for D in divisors(N):
if D == N:
L.append(H.create_element(1, 0, 0, 1))
else:
# ... the original construction for D != N ...The Why this might not be equivalent:
Two questions:
If point 1 has a clean justification, fine to keep — but the change shouldn't go in silently. |
|
Follow-up on point 3 (the d = x.determinant()
inv = d ** -1
if not (d.is_integral() and inv.is_integral() and d.is_totally_positive()):
raise TypeError("matrix must have determinant equal to totally positive unit")
Equivalent in semantics to your current check, much cheaper per call. |
…matrix_type Previously an unrecognized matrix_type fell through to the default product path silently. Now raise ValueError so typos like the recently renamed "unit" (now "Unit") fail loudly instead of silently returning the wrong shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Asserts that quantities derived from the ambient group only -- fundamental_units and basis_matrix_logarithmic_unit_lattice -- agree between a pullback constructed at a non-trivial level and one constructed at the trivial level, and that ambient_group() correctly strips the level. Covers the wider self.group() -> self.ambient_group() refactor in pullback.py. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ruff-format kept folding the long basis_matrix_logarithmic_unit_lattice comparison into a parenthesized multiline that the sage doctest parser rejects (needs `....:` continuations, not bare indentation). Assign each matrix to a short-named local first so every doctest line fits the 100-char limit on its own. Verified locally: src/hilbert_modgroup/extended/ all 1226 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Ran the full extended subpackage doctest suite locally on commit 1226 tests green including the new |
|
Thanks for pointing this out. Yes, this change was intentional. My motivation was to avoid constructing a representative that would later be replaced by the identity anyway. Looking at the So my intention was simply to insert the identity directly in this special case instead of constructing this representative first and replacing it afterwards. |
Changes include:
ambient_groupfunction to simplify several computations.