Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dict.fromkeys instead of set for deterministic behavior #67

Open
tstadel opened this issue Jul 10, 2023 · 0 comments
Open

Use dict.fromkeys instead of set for deterministic behavior #67

tstadel opened this issue Jul 10, 2023 · 0 comments

Comments

@tstadel
Copy link

tstadel commented Jul 10, 2023

Some methods use sets to ensure the uniqueness of items and rely on the order of items of the set. Python's set order is not deterministic across python interpreters, which makes it hard to control, especially during tests as there is no seed for set that can be controlled.

Using dict.fromkeys instead of set achieves the same uniqueness but guaranteeing deterministic ordering of items.

The following methods are affected:

  • PairwisePreference._current_candidates
  • Optimized._sample_rankings
  • Optimized._sample
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

No branches or pull requests

1 participant