Conversation
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| first_idx = pt.argmax(exceeds_q, axis=0) | ||
| result = k_vals[first_idx] | ||
|
|
||
| return ppf_bounds_disc(result, q, lower, upper) |
There was a problem hiding this comment.
Unreachable dead code after return statement
Medium Severity
The find_ppf_discrete function has unreachable code after line 128. The function returns at line 128 with return ppf_bounds_disc(result, q, lower, upper), but lines 129-133 contain leftover code from the previous implementation that will never execute. This appears to be dead code that was not removed during refactoring.
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Logit-normal mode formula returns median instead
Medium Severity
The mode function returns _expit(mu) which is mathematically the median of the logit-normal distribution, not the mode. The mode of a logit-normal distribution depends on both mu and sigma and requires solving a transcendental equation — it has no simple closed form. The current formula is only correct in the limiting case where sigma approaches zero.
distributions/logitnormal.py#L30-L32
distributions/distributions/logitnormal.py
Lines 30 to 32 in 79d80b9
Von Mises PPF returns infinity at finite boundaries
Medium Severity
The von_mises_ppf function returns ±inf for q=0 and q=1, but the von Mises distribution has finite support [-π, π]. Following the pattern used by other distributions in this codebase (e.g., beta.py uses ppf_bounds_cont with finite bounds), ppf(0) should return -π and ppf(1) should return π. This causes incorrect results when querying the PPF at boundary quantiles.
distributions/optimization.py#L169-L171
distributions/distributions/optimization.py
Lines 169 to 171 in 79d80b9
| # Array case - need broadcasting | ||
| exceeds_q = pt.ge(cdf_vals[:, None], q[None, :] - eps) | ||
| first_idx = pt.argmax(exceeds_q, axis=0) | ||
| result = k_vals[first_idx] |
There was a problem hiding this comment.
Direct search doesn't handle multi-dimensional q arrays
Low Severity
The _should_use_bisection function checks if params are non-scalar but doesn't check the shape of q. When q has ndim > 1 (multi-dimensional), the direct search path is incorrectly used. The array case broadcasting logic (cdf_vals[:, None] with q[None, :]) assumes q is 1D and would fail or produce incorrect results for higher-dimensional q arrays. The previous implementation always used bisection which handles any q shape correctly.
Note
Introduces CI and improves core distribution utilities.
ci.ymlrunning pre-commit and test matrix on Python 3.13 with coverage output.modeto handle edge cases (monotone/unimodal/undefined) with broadcasting-safe logic; unchangedppfdelegates to improved discrete PPF.distributions/optimization.py, adds_is_scalar_paramand_should_use_bisectionto choose between direct search over bounded support vs. bisection for wide/unbounded cases; keeps bounds handling and improves performance/readability.betabinomialcases (including non-unique modes viaskip_mode), adjustslogitnormalparameters for numerical stability, and relaxeswaldSF/logCDF tolerances slightly.testextras inpyproject.toml, pytestaddopts, switches pre-commit toruff-check, and updates.gitignorefor coverage artifacts.Written by Cursor Bugbot for commit 3172720. This will update automatically on new commits. Configure here.