summaryrefslogtreecommitdiff
path: root/numpy/ma
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/ma')
-rw-r--r--numpy/ma/core.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 98100621e..673cfb1ab 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -940,7 +940,9 @@ class _MaskedBinaryOperation:
# Revert result to da where masked
if m.any():
np.putmask(result, m, 0)
- result += m * da
+ # This only makes sense if the operation preserved the dtype
+ if result.dtype == da.dtype:
+ result += m * da
# Transforms to a (subclass of) MaskedArray
result = result.view(get_masked_subclass(a, b))
result._mask = m