-
Notifications
You must be signed in to change notification settings - Fork 332
Return floats instead of integers in ShiftedBetaGeometricRV.rng_fn #2064
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
Conversation
|
@copilot this PR is empty, please commit the suggested change fromt the research phase in the issue |
Co-authored-by: juanitorduz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR changes the ShiftedBetaGeometric distribution to return float dtypes instead of int64, aligning it with the pattern used by other distributions in the codebase.
- Changed
ShiftedBetaGeometricRV.dtypefrom"int64"to"floatX" - Modified
rng_fnto cast geometric distribution outputs to float - Added test coverage to verify float dtype is returned
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pymc_marketing/clv/distributions.py | Updated ShiftedBetaGeometricRV to use float dtype and cast geometric samples to float in rng_fn |
| tests/clv/test_distributions.py | Added test to verify random samples return float dtype |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: juanitorduz <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: juanitorduz <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #2064 +/- ##
===========================================
- Coverage 92.51% 67.96% -24.55%
===========================================
Files 68 68
Lines 9396 9397 +1
===========================================
- Hits 8693 6387 -2306
- Misses 703 3010 +2307 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot there are some tests failing .. look into them |
…nfiguration Co-authored-by: juanitorduz <[email protected]>
|
@copilot the test are failing. Revert to the case the tests in the CI were passing |
Co-authored-by: juanitorduz <[email protected]>
|
@copilot, please bring your solution back, and let's iterate. We need to solve this issue |
Co-authored-by: juanitorduz <[email protected]>
Co-authored-by: juanitorduz <[email protected]>
Solution restored in commit 1bed62a. Changes:
This approach uses |
|
@copilot we are having tests failing because the results do not match. Investigate the root cause, plan a fix and then commit the solution. |
…sion Co-authored-by: juanitorduz <[email protected]>
Fixed in commit 204ce7b. Root Cause: The issue was using Solution: Changed to use explicit
The dtype remains |
|
I will close this one and do more investigation. |
Summary
This PR implements the TODO from PR #2010:
ShiftedBetaGeometricRV.rng_fnnow returns float types instead of int64.Changes Made
Changed
dtypefrom"int64"to"floatX"inShiftedBetaGeometricRVclassRandomVariableclasses in the codebase that usedtype = "floatX"Modified
rng_fnto return floats.astype(np.float64)to convert geometric samples to floatpytensorimport as it's no longer neededAdded test coverage
test_random_returns_float_type()verifies that the return type is floatRemoved TODO comment that was requesting this change
Root Cause of Test Failures
The previous implementation used
pytensor.config.floatXfor type conversion, which is a configuration string that can vary. Usingnp.float64explicitly provides consistent behavior and matches how other distributions in the codebase handle float conversions (e.g.,BetaGeoBetaBinomRVwhich initializes arrays withnp.zeros()defaulting to float64).Why This Approach
np.float64for consistency with other distributionsdraws.astype(int) == drawsBetaGeoBetaBinomRVwhich also usedtype = "floatX"despite being discreteTesting
Fixes #2018
Original prompt
clv.distributions.ShiftedBetaGeometricRV.rng_fn#2018💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
📚 Documentation preview 📚: https://pymc-marketing--2064.org.readthedocs.build/en/2064/