Skip to content

Add public testing function to mock sample #7761

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 14 commits into from
May 1, 2025

Conversation

williambdean
Copy link
Contributor

@williambdean williambdean commented Apr 22, 2025

Description

Related to pymc-devs/pymc-extras#464

CC: @jessegrabowski

Related Issue

  • Closes #
  • Related to #

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

@williambdean
Copy link
Contributor Author

Maybe mock_sample isn't the best name for this function. Open to suggestions here

@jessegrabowski
Copy link
Member

The name is OK for me, not sure what would be better

@williambdean
Copy link
Contributor Author

williambdean commented Apr 22, 2025

I guess mock sounds like both a verb and adjective

@jessegrabowski
Copy link
Member

It's clear from the context which is being used

@williambdean
Copy link
Contributor Author

williambdean commented Apr 22, 2025

Another subtle item here is that Flat and HalfFlat will not be mocked with this function. But that is seems a bit separate

That was needed for this: https://github.com/williambdean/pymc-examples/blob/69563da49ceef589127140d3675a05b2ba4c3ae0/scripts/run_notebooks/injected.py#L72-L74

@jessegrabowski
Copy link
Member

We could rewrite Flat and HalfFlat to Uniform and HalfUniform with big bounds (like -1e9 to 1e9) for the purposes of the tests? Is that too overkill?

@williambdean
Copy link
Contributor Author

We could rewrite Flat and HalfFlat to Uniform and HalfUniform with big bounds (like -1e9 to 1e9) for the purposes of the tests? Is that too overkill?

I think that would be in the actual fixture since that provides the setup and breakdown. This function by itself doesn't

@jessegrabowski
Copy link
Member

jessegrabowski commented Apr 22, 2025

Yeah for sure. But a flat-to-uniform model transformation might potentially be in-scope for this PR

@williambdean
Copy link
Contributor Author

Did HalfNormal and Normal. How's that?

And as for the use, does that seem reasonable for how others will define? It would require pytest to be an explicit dependency otherwise

Copy link

codecov bot commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.84%. Comparing base (d34ed95) to head (d3a8c1c).
Report is 5 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7761   +/-   ##
=======================================
  Coverage   92.83%   92.84%           
=======================================
  Files         107      107           
  Lines       18343    18367   +24     
=======================================
+ Hits        17028    17052   +24     
  Misses       1315     1315           
Files with missing lines Coverage Δ
pymc/testing.py 90.30% <100.00%> (+0.52%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94 ricardoV94 changed the title function to mock pm.sample Add public testing function to mock sample Apr 24, 2025
@ricardoV94
Copy link
Member

We should add an entry to the docs

@williambdean
Copy link
Contributor Author

williambdean commented Apr 24, 2025

We should add an entry to the docs

Done

@williambdean
Copy link
Contributor Author

What else is required here?

Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

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

lgtm

@michaelosthege michaelosthege merged commit 7bf58d5 into pymc-devs:main May 1, 2025
25 checks passed
@williambdean williambdean deleted the mock-sample branch May 1, 2025 09:22
@jessegrabowski
Copy link
Member

@fonnesbeck can we do a release so we can use this tool in extras?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants