summaryrefslogtreecommitdiff
path: root/numpy/ma/core.py
diff options
context:
space:
mode:
authorTyler Reddy <tyler.je.reddy@gmail.com>2023-02-24 09:39:40 -0700
committerTyler Reddy <tyler.je.reddy@gmail.com>2023-02-24 10:00:02 -0700
commit2282c6d8e6c9ea81e6e687c4bccb628d1b209adc (patch)
treee160a15262371cc8915af837c4eb906c277223a7 /numpy/ma/core.py
parentc61900d5675d4a33a893da5c8e343b6c0c1666dd (diff)
downloadnumpy-2282c6d8e6c9ea81e6e687c4bccb628d1b209adc.tar.gz
MAINT: PR 23269 revisions
* guard masked array `__deepcopy__` special object handling behind `dtype.hasobject`, based on reviewer feedback * masked array `__deepcopy__` for object type handling now deepcopies from `self._data` directly, based on reviewer feedback * add a test case for 2D masked array object deepcopies, since reviewer was not convinced this was working
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r--numpy/ma/core.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 795e79e00..107687e8b 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -6310,9 +6310,8 @@ class MaskedArray(ndarray):
# deepcopy() directly for arrays of object type that may
# contain compound types--you cannot depend on normal
# copy semantics to do the right thing here
- if self.dtype.type is np.object_:
- for idx, _ in enumerate(copied):
- copied[idx] = deepcopy(copied[idx])
+ if self.dtype.hasobject:
+ copied = deepcopy(self._data)
return copied