Problem
Three public, exported truncated distributions define a .var property but not the standard .variance:
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:
import numpyro.distributions as dist
d = dist.LeftTruncatedDistribution(dist.Normal(0, 1), low=0.0)
d.var # -> works, returns the variance
d.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).
Problem
Three public, exported truncated distributions define a
.varproperty but not the standard.variance:LeftTruncatedDistribution—truncated.py:123RightTruncatedDistribution—truncated.py:211TwoSidedTruncatedDistribution—truncated.py:357The canonical statistic across every other distribution (and the
Distributionbase class) is.variance. Because these classes only define.var, calling the standard.variancefalls through to the base-class property, whichraise NotImplementedError:The
.varbodies compute the truncated-Normal variance correctly — they're just exposed under a non-standard name, so the documented.varianceAPI is broken for these three distributions.Proposed fix
Rename
var→varianceon all three classes. This is safe and self-contained:.varon these distributions (the only.varreferences — indiagnostics.pyandtest_distributions.py— arenumpy/scipy.var()calls, unrelated)..varianceAPI.Optionally add a test asserting
.variancereturns the value for these truncated distributions (the existing suite only exercised the wrongly-named.varindirectly, if at all).