diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-04-04 20:20:40 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-04-04 20:20:40 +0000 |
commit | 204efabe8d40e0ff8b7e81518476eb5253e4d09d (patch) | |
tree | 01cc1ed68dfa6ff5866e7c2943998954da98a669 /numpy/core/_internal.py | |
parent | 64e70811b58ade22a4a2c4be24b41dec23303942 (diff) | |
download | numpy-204efabe8d40e0ff8b7e81518476eb5253e4d09d.tar.gz |
BUG: core: fix bugs in PEP 3118 format string parsing
- Handle consecutive characters (eg. 'xxxx') properly
- Compute native padding correctly
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r-- | numpy/core/_internal.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 74df9b926..d7f1a1119 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -454,10 +454,10 @@ def _dtype_from_pep3118(spec, byteorder='@', is_subdtype=False): # Not supported raise ValueError("Non item-size 1 structures not supported") elif spec[0] in type_map_chars: - j = 1 - for j in xrange(1, len(spec)): - if spec[j] not in type_map_chars: - break + if spec[0] == 'Z': + j = 2 + else: + j = 1 typechar = spec[:j] spec = spec[j:] is_padding = (typechar == 'x') @@ -476,8 +476,8 @@ def _dtype_from_pep3118(spec, byteorder='@', is_subdtype=False): # that the start of the array is *also* aligned. extra_offset = 0 if byteorder == '@': - start_padding = offset % value.alignment - intra_padding = value.itemsize % value.alignment + start_padding = (-offset) % value.alignment + intra_padding = (-value.itemsize) % value.alignment offset += start_padding |