Repository navigation
bijectionist: make value restrictions complain early - #42967
Merged
vbraun merged 2 commits intoOct 18, 2026
Merged
Conversation
…en restriction is empty
Previously, Bijectionist.set_value_restrictions() silently stored an empty
intersection when none of the specified values appeared in Z, only raising
a ValueError later when _compute_possible_block_values() was called (i.e.
during solutions_iterator()). This made it hard to catch typos.
This commit raises a descriptive ValueError immediately in
set_value_restrictions() when the intersection of the given values with Z
is empty, giving the user an actionable message right away:
ValueError: the value restriction for element 1 is empty:
none of the given values [4] lie in Z = {1, 2, 3}
This also catches the common iterable-element mistake of passing a tuple
of allowed values instead of a list (e.g. set_value_restrictions((a, (v1,v2)))
instead of set_value_restrictions((a, [v1, v2]))).
Updated docstring with two new EXAMPLES and updated TESTS to reflect the
new (earlier) error point. The _compute_possible_block_values() test is
updated to bypass the public API directly, since the old test case no
longer reaches that method.
Fixes sagemath#36265
|
Documentation preview for this PR (built with commit b65ddcd; changes) is ready! 🎉 |
Contributor
Author
|
please also change label, unless you want a second look! |
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Oct 16, 2026
sagemathgh-42967: bijectionist: make value restrictions complain early supersedes sagemath#42700, fixes sagemath#36265 URL: sagemath#42967 Reported by: Martin Rubey Reviewer(s): David Coudert
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.
supersedes #42700, fixes #36265