summaryrefslogtreecommitdiff
path: root/numpy/lib/format.py
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2019-04-30 06:47:29 -0400
committermattip <matti.picus@gmail.com>2019-04-30 06:59:09 -0400
commit666d92ac85a6adf0fec7361c3340fc6ab12c8330 (patch)
treea10461ceaf1b839c9383c69bcd800d2569c3058d /numpy/lib/format.py
parentc23bd98de665733dd090636f38b6aacf9f99450b (diff)
downloadnumpy-666d92ac85a6adf0fec7361c3340fc6ab12c8330.tar.gz
BUG: handle subarrays in descr_to_dtype
Diffstat (limited to 'numpy/lib/format.py')
-rw-r--r--numpy/lib/format.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py
index 553c9371d..abd98dd22 100644
--- a/numpy/lib/format.py
+++ b/numpy/lib/format.py
@@ -261,12 +261,13 @@ def dtype_to_descr(dtype):
def descr_to_dtype(descr):
'''
descr may be stored as dtype.descr, which is a list of
- (name, format, [shape]) tuples. Offsets are not explicitly saved, rather
- empty fields with name,format == '', '|Vn' are added as padding.
+ (name, format, [shape]) tuples where format may be a str or a tuple.
+ Offsets are not explicitly saved, rather empty fields with
+ name, format == '', '|Vn' are added as padding.
This function reverses the process, eliminating the empty padding fields.
'''
- if isinstance(descr, (str, dict)):
+ if isinstance(descr, (str, dict, tuple)):
# No padding removal needed
return numpy.dtype(descr)