summaryrefslogtreecommitdiff
path: root/numpy/ma/core.py
diff options
context:
space:
mode:
authorpierregm <pierregm@localhost>2008-12-02 08:50:11 +0000
committerpierregm <pierregm@localhost>2008-12-02 08:50:11 +0000
commitac338653590e858f7a9f96a84a6de9a6cdc6b323 (patch)
tree1f740c879f124a617093a7559c0b3b2cd7ba94c6 /numpy/ma/core.py
parent2dd04cee57d2d4a29bf4c0c8e4024494d3e499f1 (diff)
downloadnumpy-ac338653590e858f7a9f96a84a6de9a6cdc6b323.tar.gz
* Fixed make_mask_descr for dtype w/ composite names, like [(('A','B'), float)]
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r--numpy/ma/core.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index a8922a597..510a59d1a 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -800,12 +800,19 @@ def make_mask_descr(ndtype):
"""
def _make_descr(datatype):
"Private function allowing recursion."
+ datatype = np.dtype(datatype)
# Do we have some name fields ?
- names = datatype.names
- if names:
+ if datatype.names:
descr = []
- for name in names:
- (ndtype, _) = datatype.fields[name]
+ # !!!: If one of the fieldnames is a tuple, only its last element
+ # !!!: is listed in datatype.names: we need to take datatype.descr.
+ for name in (_[0] for _ in datatype.descr):
+ # Take the last element of the tuple as key for datatype.fields
+ if isinstance(name, tuple):
+ # datatype.fields[name] is a tuple of 2 or 3 element...
+ ndtype = datatype.fields[name[-1]][0]
+ else:
+ ndtype = datatype.fields[name][0]
descr.append((name, _make_descr(ndtype)))
return descr
# Is this some kind of composite a la (np.float,2)