Skip to content

Releases: will-keen/constrainedrandom

Release list

1.3.0

Choose a tag to compare

@will-keen will-keen released this 19 Sep 14:34

Results with the same problem and same seed may differ from 1.2.2. The entries under Changed say for which problems.

Added

  • Derived variables: add_rand_var(..., fn=..., rand_var_args=(...)) computes a variable's value from other variables.
  • randomize(with_values=...) validates the given values against domains and constraints. Pass check_with_values=False to skip.
  • RandObj.set_random(_random) sets the random generator after construction, for the object and every variable already added.

Changed

  • range domains use their step. Seeded results change for stepped ranges.
  • weighted_choice returns the chosen value rather than a single-element list.
  • The naive solver calls the random generator once less per attempt. Seeded results change for problems with multi-variable constraints.
  • Variables are randomized in the order they were added. Seeded results change for objects whose variables were added in non-alphabetical order.
  • python -m tests selects tests by package-relative name, e.g. features.basic.BasicFeatures.

Fixed

  • Constraining a random-length list no longer holds its length constant.
  • randomize(with_values=...) no longer raises IndexError when every constrained variable is given a value.
  • A list given in with_values is no longer overwritten when its length variable is re-randomized.
  • functools.partial objects and other callables are no longer rejected as constraints.
  • A failed add_constraint no longer leaves the object unusable.
  • Using a random-length list as another variable's rand_length now raises an error.
  • Failure messages no longer omit debug information.
  • The CSP solve order is rebuilt when a random-length list's length changes, so results no longer depend on earlier randomizations. Seeded results change for problems with random-length lists that reach the CSP solver.

Performance

  • Constraints on concrete values are checked directly rather than via the constraint package. 3.5x faster on ldInstr, up to 7.6x on multi-variable naive solving.
  • is_pure treats a functools.partial of a pure function with immutable arguments as pure.

Development

  • CI runs the tests on Linux, Windows and macOS and builds the docs with warnings as errors.
  • ruff formats and lints the code, enforced in CI.

https://pypi.org/project/constrainedrandom/1.3.0/

1.2.2

Choose a tag to compare

@will-keen will-keen released this 14 Oct 11:44