You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Truncated distributions define .var instead of .variance, so .variance raises NotImplementedError #2
The canonical statistic across every other distribution (and the Distribution base class) is .variance. Because these classes only define .var, calling the standard .variance falls through to the base-class property, which raise NotImplementedError:
importnumpyro.distributionsasdistd=dist.LeftTruncatedDistribution(dist.Normal(0, 1), low=0.0)
d.var# -> works, returns the varianced.variance# -> NotImplementedError (standard API is silently broken)
The .var bodies compute the truncated-Normal variance correctly — they're just exposed under a non-standard name, so the documented .variance API is broken for these three distributions.
Proposed fix
Rename var → variance on all three classes. This is safe and self-contained:
No caller in the codebase reads .var on these distributions (the only .var references — in diagnostics.py and test_distributions.py — are numpy/scipy.var() calls, unrelated).
Restores the standard .variance API.
Optionally add a test asserting .variance returns the value for these truncated distributions (the existing suite only exercised the wrongly-named .var indirectly, if at all).
Activity