Skip to content

Commit 83c9f3d

Browse files
committed
Fix bug whereby adding unitful NDCube and NDData did not output result with underlying arrays as dask.
1 parent 5671bde commit 83c9f3d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

changelog/880.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adding unitful `~ndcube.NDCube` and ``astropy.nddata.NDData`` objects backed by ``dask`` did not preserve underlying arrays as ``dask`` arrays. This is now fixed.

ndcube/ndcube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ def _arithmetic_operate_with_nddata(self, operation, value):
983983
if operation == "add":
984984
# Handle units
985985
if self.unit is not None and value.unit is not None:
986-
value_data = (value.data * value.unit).to_value(self.unit)
986+
value_data = value.data * (value.unit / self.unit).to(u.dimensionless_unscaled)
987987
elif self.unit is None and value.unit is None:
988988
value_data = value.data
989989
else:

0 commit comments

Comments
 (0)