astrofrog / astrofrog/numtraits
Zero-dimensional arrays should be accepted as scalars
- Dominant language
- Python
- Stars
- 39
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Currently, zero-dimensional arrays get rejected on `NumericalTrait(ndim=0)`, as the latter requires the value to be `np.isscalar`. Unfortunately `np.isscalar(np.array(1)) == False`. The error is particularly annoying in conjunction with quantities, as `quantities.Quantity` is a subclass of `np.ndarray` and thus it's instances are not numpy array scalars.
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate NumericalTrait(ndim=0) and the np.isscalar check. Reproduce the issue with np.array(1) and quantities.Quantity, then inspect the existing validation tests. Done means zero-dimensional arrays are accepted as scalars while nonzero-dimensional arrays remain rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100