Skip to content

bijectionist: make value restrictions complain early - #42967

Merged
vbraun merged 2 commits into
sagemath:developfrom
mantepse:bijectionist/value-restrictions
Oct 18, 2026
Merged

vbraun merged 2 commits into
sagemath:developfrom
mantepse:bijectionist/value-restrictions

Conversation

@mantepse

@mantepse mantepse commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

supersedes #42700, fixes #36265

Chaitanya140904 and others added 2 commits October 13, 2026 15:54
…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
@mantepse mantepse changed the title bijectionist/value restrictions bijectionist: make value restrictions complain early Oct 13, 2026
@github-actions

Copy link
Copy Markdown

Documentation preview for this PR (built with commit b65ddcd; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@dcoudert dcoudert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mantepse

Copy link
Copy Markdown
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
Release Manager
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
@vbraun
vbraun merged commit 8a0b72e into sagemath:develop Oct 18, 2026
25 checks passed
@mantepse
mantepse deleted the bijectionist/value-restrictions branch October 18, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The bijectionist should complain if a value restriction gives an empty set

4 participants