Skip to content

Added seeding to draws in tests #195

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

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

pdb5627
Copy link
Contributor

@pdb5627 pdb5627 commented Jun 11, 2023

Fixes #192
Added seeding to tests that draw from random variables and check the values drawn.

Added seeding to tests that draw from random variables and check the
values drawn.
Copy link
Collaborator

@michaelraczycki michaelraczycki left a comment

Choose a reason for hiding this comment

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

looks good to me, this should do the job. Thanks!

@michaelraczycki michaelraczycki merged commit 4ea3151 into pymc-devs:main Jun 12, 2023
with pm.Model() as m_old:
x = pm.Normal("x", 0, 1e-3)
y = pm.Normal("y", x, 1e-3)
z = pm.Normal("z", y + x, 1e-3)

assert -5 < pm.draw(z) < 5
assert -5 < pm.draw(z, random_seed=rng) < 5
Copy link
Member

Choose a reason for hiding this comment

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

These ones didn't need seeding but no harm I guess. They were selected to be many standard deviations away from the constraint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that, but in my recent and limited experience with the project I observed that random test failure gets flagged as a flaky test issue, so I thought it would be better to seed. Do you have a sense of what probability of test failure the project would accept?

Copy link
Member

@ricardoV94 ricardoV94 Jun 12, 2023

Choose a reason for hiding this comment

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

Those are the sum of 3 Normals each with 1e-3 standard deviation, so to get out of the (-5, 5) range, it should take a couple of universe lifetimes :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, yes, in this case the chance is very small. For my own learning, I just wondered where (approximately) you might draw the line.

@pdb5627 pdb5627 deleted the seed-draws-in-tests branch June 13, 2023 08:09
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.

fix test_random_draws flakiness
3 participants