Skip to content

Fix a round of issues#2

Open
will-keen wants to merge 10 commits into
masterfrom
willk/bug_fixes
Open

Fix a round of issues#2
will-keen wants to merge 10 commits into
masterfrom
willk/bug_fixes

Conversation

@will-keen

Copy link
Copy Markdown
Owner

Each one contains a description and a unit test

will-keen added 10 commits June 11, 2026 10:45
debug_info was assigned the typing construct
Optional[RandomizationDebugInfo] instead of a value, so failure
paths could stringify the typing object rather than real debug
info. Initialise it to None.
The check only looked at 'length', so a list whose length is itself
random was accepted as a rand_length variable, despite a list-valued
length being illegal. Use is_list(), which covers both fixed and
random lengths.
Both error messages interpolated the variable being added rather
than the offending rand_length argument, making them misleading.
Range domains were randomized with randrange(start, stop), ignoring
the step. Values outside the domain were returned, and ranges with
a negative step raised ValueError.
Constraining a random-length list did not mark the variable defining
its length as constrained. The length then kept its first random
value through all solver stages, so solvable problems failed.
Propagate in add_constraint and for temporary constraints.
When with_values gave a value for every variable in a
MultiVarProblem, determine_order indexed an empty list and raised
IndexError. Use one empty group so the values are still checked
against the constraints.
When a constrained length variable was re-randomized, its dependent
list variables were re-randomized too, even when given a concrete
value in with_values, discarding the given value.
is_pure raised TypeError for callables such as functools.partial,
because getclosurevars only accepts plain functions. This made
add_rand_var and add_constraint crash for such constraints. Treat
them as impure instead.
add_constraint appended the constraint before checking the variable
names, so a failed call left the constraint registered and every
later randomize raised KeyError.
weighted_choice returned the single-element list from
random.choices, contradicting its docstring. Return the value
itself. dist no longer needs to index the result.
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.

1 participant