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
astropy.uncertainty.Distribution has an associated ScalarDistribution type that is used for single elements (with still multiple samples). It was noted in numpy/numpy#32744 (review) that indexing this scalar with ... returns an array, not a distribution.
The docstring of ScalarDistribution notes that it exists mostly to help make array2print possible for all subclasses. We perhaps should revisit that, since for other ndarray subclasses (Masked, Quantity), we do not have specific scalar types.
Alternatively (but less preferred), we need to make sure the indexing works correctly.
Expected behavior
d[...] should return a Distribution independent of whether d is scalar or array.
How to Reproduce
# create scalars=Distribution(np.arange(12.).reshape(3, 4))[0]
s# astropy.uncertainty.core.ScalarDistribution(([(0.0,), (1.0,), (2.0,), (3.0,)],), dtype=|V8)# tried to get back to array, expecting Distributions[...]
# array(([(0.,), (1.,), (2.,), (3.,)],),# dtype=(astropy.uncertainty.core.ScalarDistribution, [('samples', [('sample', '<f8')], (4,))]))
@mhvk , I would like to work on issue. I have reproduced the bug locally. my curent plan is to remove scalarDistribution completely and see how test suite behaves around array2print, can i start working on issue ?
@mhvk , Itried both the approaches mentioned by you on removing ScalarDistribution class the test breaks at 6 test in distribution.py file giving Valueerror and indexerror, we will need to fix it 2nd on adding handler in ScalarDistribution.getitem the bug got sucessfully fixed and it didn't even break on any test.
so, what would you suggest should i go with approach 1 or 2 ?
Activity
pllim commentedon Sep 22, 2026
Looks like @eteq is a co-maintainer of uncertainty along with you, so maybe he can comment also? Thanks!
mhvk commentedon Sep 22, 2026
Indeed, though I'm pretty sure I'm the one to blame for introducing
ScalarDistribution...Onkar-Raskar commentedon Oct 15, 2026
@mhvk , I would like to work on issue. I have reproduced the bug locally. my curent plan is to remove scalarDistribution completely and see how test suite behaves around array2print, can i start working on issue ?
mhvk commentedon Oct 18, 2026
@Onkar-Raskar - we do not assign issues. I think this one will require some fairly detailed digging in to how
array2printworks.Onkar-Raskar commentedon Oct 21, 2026
@mhvk , Itried both the approaches mentioned by you on removing ScalarDistribution class the test breaks at 6 test in distribution.py file giving Valueerror and indexerror, we will need to fix it 2nd on adding handler in ScalarDistribution.getitem the bug got sucessfully fixed and it didn't even break on any test.
so, what would you suggest should i go with approach 1 or 2 ?
mhvk commentedon Oct 21, 2026
@Onkar-Raskar - I'd prefer getting rid of
ScalarDistributioneventually, but I'm OK with having a work-around for now of just introducing__getitem__