Skip to content

Fix/windows overflow #364

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- bump: patch
changes:
fixed:
- Removed the possibility of a negative seed in random() within commons/formulas.py
changed:
- As part of the negative seed fix in formulas.py, a single seed and generator was used to generate a random sequence, rather than a random number generator and seed combination being deployed for each entity id. This saves around 5-10 seconds of computation.
9 changes: 2 additions & 7 deletions policyengine_core/commons/formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,8 @@ def random(population):
entity_ids = population(f"{population.entity.key}_id", period)

# Generate random values for each entity
values = np.array(
[
np.random.default_rng(
seed=id * 100 + population.simulation.count_random_calls
).random()
for id in entity_ids
]
values = np.random.default_rng(seed=min(entity_ids)).random(
size=len(entity_ids)
)

return values
Expand Down