Bug/feature request: convert/convert_unitted
- Dominant language
- Python
- Stars
- 66
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
[I feel like I have had this conversation before, but can't find trace of it anymore. Hope it is not a duplicate]
I keep forgetting that the `convert` function only works for float, not `UnitScalar`s. As a result, and because `UnitScalar` is a subclass of `np.ndarray`, the following happens:
```
In [3]: from scimath.units.api import convert, UnitScalar
In [4]: x = UnitScalar(1., units="cm")
In [5]: from scimath.units.length import meter
In [6]: convert(x, from_unit=x.units, to_unit=meter)
Out[6]: UnitScalar(0.01, units='0.01*m')
```
which feels very buggy. I believe that we should:
1. either raise an exception when a `UnitScalar` is passed, and create a new `convert_unitted` function that accepts `UnitScalar`s/`UnitArray`s
2. or support the `UnitScalar`s correctly.
I think I like option 2 better, but it makes things not backward compatible, so is probably a no go.
Opinions? @timdiller @rkern ?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.