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
In [3]: c=NDData(np.zeros((10,10)), unit=u.count)
In [4]: u.Quantity(c)
---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)
CellIn[5], line1---->1u.Quantity(c)
File~/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/astropy/units/quantity.py:552, inQuantity.__new__(cls, value, unit, dtype, copy, order, subok, ndmin)
548# check that array contains numbers or long int objects549ifvalue.dtype.kindin"OSU"andnot (
550value.dtype.kind=="O"andisinstance(value.item(0), numbers.Number)
551 ):
-->552raiseTypeError("The value must be a valid Python or Numpy numeric type.")
554# by default, cast any integer, boolean, etc., to float555iffloat_defaultandvalue.dtype.kindin"iuO":
TypeError: ThevaluemustbeavalidPythonorNumpynumerictype.
Describe the desired outcome
a NDData object has a .unit and is "array like" I feel like this should work, and be equivalent to u.Quantity(c.data, unit=c.unit).
Additional context
No response
The text was updated successfully, but these errors were encountered:
I'm hoping that in Q2.0 we simplify the construction of Quantity, further optimizing it for speed. Like NumPy, Jax, etc have asarray we would then provide a quantity() function that munges all the various objects into a Quantity. So yes, this should be supported!
What is the problem this feature will solve?
Describe the desired outcome
a NDData object has a .unit and is "array like" I feel like this should work, and be equivalent to
u.Quantity(c.data, unit=c.unit)
.Additional context
No response
The text was updated successfully, but these errors were encountered: