summaryrefslogtreecommitdiff
path: root/numpy/core/_internal.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2010-02-21 02:52:39 +0000
committerPauli Virtanen <pav@iki.fi>2010-02-21 02:52:39 +0000
commit3f8f41bb3150b99407b3bbc9bac087fe07ceb009 (patch)
tree5dac7c3322b01279865e8a76837e0055ed32f0d3 /numpy/core/_internal.py
parent2e7b3277001937b0c8ad01c7671912d6a4b8f610 (diff)
downloadnumpy-3f8f41bb3150b99407b3bbc9bac087fe07ceb009.tar.gz
3K: ENH: core: support BOOL and VOID better in PEP 3118 buffers
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r--numpy/core/_internal.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py
index 56acfb757..109da1567 100644
--- a/numpy/core/_internal.py
+++ b/numpy/core/_internal.py
@@ -351,6 +351,7 @@ def _index_fields(ary, fields):
# construct a Numpy dtype
_pep3118_map = {
+ '?': '?',
'b': 'b',
'B': 'B',
'h': 'h',
@@ -373,6 +374,7 @@ _pep3118_map = {
'O': 'O',
'x': 'V', # padding
}
+_pep3118_typechars = ''.join(_pep3118_map.keys())
def _dtype_from_pep3118(spec, byteorder='=', is_subdtype=False):
from numpy.core.multiarray import dtype
@@ -421,10 +423,10 @@ def _dtype_from_pep3118(spec, byteorder='=', is_subdtype=False):
if itemsize != 1:
# Not supported
raise ValueError("Non item-size 1 structures not supported")
- elif spec[0].isalpha():
+ elif spec[0] in _pep3118_typechars:
j = 1
for j in xrange(1, len(spec)):
- if not spec[j].isalpha():
+ if spec[j] not in _pep3118_typechars:
break
typechar = spec[:j]
spec = spec[j:]
@@ -446,16 +448,18 @@ def _dtype_from_pep3118(spec, byteorder='=', is_subdtype=False):
value = dtype((value, shape))
# Field name
+ this_explicit_name = False
if spec and spec.startswith(':'):
i = spec[1:].index(':') + 1
name = spec[1:i]
spec = spec[i+1:]
explicit_name = True
+ this_explicit_name = True
else:
name = 'f%d' % findex
findex += 1
- if not is_padding:
+ if not is_padding or this_explicit_name:
fields[name] = (value, offset)
offset += value.itemsize