Skip to content

Use mock sample in tests #489

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 7 commits into
base: main
Choose a base branch
from

Conversation

williambdean
Copy link
Contributor

@williambdean williambdean commented Jun 16, 2025

Saving about 50s in the test suite by mocking pm.sample


📚 Documentation preview 📚: https://causalpy--489.org.readthedocs.build/en/489/

Copy link

codecov bot commented Jun 16, 2025

Codecov Report

Attention: Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.33%. Comparing base (a626c1e) to head (9250f3d).

Files with missing lines Patch % Lines
causalpy/tests/conftest.py 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #489      +/-   ##
==========================================
- Coverage   94.40%   94.33%   -0.08%     
==========================================
  Files          29       29              
  Lines        2075     2083       +8     
==========================================
+ Hits         1959     1965       +6     
- Misses        116      118       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@williambdean
Copy link
Contributor Author

66s -> 16s test suite runs. nice

@williambdean williambdean added the no releasenotes Skipped in automatic release note generation label Jun 16, 2025
@williambdean
Copy link
Contributor Author

Doing for doctest would be greater reduction of time

@williambdean
Copy link
Contributor Author

williambdean commented Jun 16, 2025

6m31s down to 1m58s

Copy link
Collaborator

@drbenvincent drbenvincent left a comment

Choose a reason for hiding this comment

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

This is pretty cool - thanks for the contribution.

On my local machine...

  • make test runs in 24 seconds (down from 50 seconds on main) ✅
  • make doctest speed is unchanged❓

I guess I just have some questions to make sure I understand this

  • mock_sample_for_doctest kind of looks transparent in that we're overriding pm.sample with pymc.testing.mock_sample. Though that's not working or doing much?
  • mock_pymc_sample is provided as an input to tests (like test_did for example) but it's never used anywhere in those test functions. So this is a bit confusing. Does this make the use of sample_kwargs irrelevant now?

@williambdean
Copy link
Contributor Author

Noticing that too. Weird thing is pytest --doctest-modules seems to work for me but pytest --doctest-modules causalpy/ does not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no releasenotes Skipped in automatic release note generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants