Repository navigation
Fix IntegerVectorsModPermutationGroup caching for different domains - #43088
Merged
Merged
Conversation
mantepse
approved these changes
Oct 31, 2026
mantepse
left a comment
Contributor
There was a problem hiding this comment.
looks reasonable, thank you!
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Oct 31, 2026
…ifferent domains `IntegerVectorsModPermutationGroup` can reuse a cached parent for a permutation group with a different domain. For example, constructing the parents for `(1,2)` acting on `[1,2]` and `[1,2,3]`, both with sum 3, currently makes both return two-coordinate vectors. Reversing construction order changes which incorrect result is obtained. Include `tuple(G.domain())` in the `UniqueRepresentation` cache key of both concrete parent classes. This preserves caching and pickle identity while distinguishing different domains. The tuple retains the domain order because that order determines vector coordinates. Constructor normalization also covers direct calls to the concrete classes and `.subset()`, and recomputes the internal domain argument when unpickling. The reported example now returns: ```text [[3, 0], [2, 1]] [[3, 0, 0], [2, 1, 0], [2, 0, 1], [1, 1, 1], [1, 0, 2], [0, 0, 3]] ``` Replace the workaround warning with regression tests for the original example, reversed construction order, unconstrained parents, subsets, trivial actions and empty domains, repeat construction, and pickling. Retain `UniqueRepresentation`, avoiding the pickle-equality problem reported when removing it. This is a local fix; permutation-group equality and ordering remain the subject of sagemath#36912. Fixes sagemath#36527. Validation: - All 248 module doctests passed, including long tests and the new regressions. - A separate local check compared 220 constrained cases against independent brute-force orbit enumeration in both construction orders, using natural, labeled and reordered domains and explicit/default strong generating systems. Also checked unconstrained and maximum-part-only parents, repeated construction, parent pickle identity, and `TestSuite` on nonempty domains. - Both Ruff modes and `git diff --check` passed. The tests loaded the modified Python module into the installed Homebrew Sage 11.0.beta1 environment; this was not a full rebuild of the current source tree. Broader checks also reproduced existing empty-domain bugs (`an_element()` returning `[0]`, and bounded enumeration calling `max([])`); those are outside this cache-key fix. Empty-domain enumeration without a bound and parent pickle identity are covered here. URL: sagemath#43088 Reported by: Dima Pasechnik Reviewer(s): Martin Rubey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IntegerVectorsModPermutationGroupcan reuse a cached parent for a permutation group with a different domain. For example, constructing the parents for(1,2)acting on[1,2]and[1,2,3], both with sum 3, currently makes both return two-coordinate vectors. Reversing construction order changes which incorrect result is obtained.Include
tuple(G.domain())in theUniqueRepresentationcache key of both concrete parent classes. This preserves caching and pickle identity while distinguishing different domains. The tuple retains the domain order because that order determines vector coordinates. Constructor normalization also covers direct calls to the concrete classes and.subset(), and recomputes the internal domain argument when unpickling.The reported example now returns:
Replace the workaround warning with regression tests for the original example, reversed construction order, unconstrained parents, subsets, trivial actions and empty domains, repeat construction, and pickling. Retain
UniqueRepresentation, avoiding the pickle-equality problem reported when removing it. This is a local fix; permutation-group equality and ordering remain the subject of #36912.Fixes #36527.
Validation:
TestSuiteon nonempty domains.git diff --checkpassed.The tests loaded the modified Python module into the installed Homebrew Sage 11.0.beta1 environment; this was not a full rebuild of the current source tree. Broader checks also reproduced existing empty-domain bugs (
an_element()returning[0], and bounded enumeration callingmax([])); those are outside this cache-key fix. Empty-domain enumeration without a bound and parent pickle identity are covered here.