diff options
author | ahaldane <ealloc@gmail.com> | 2016-07-07 19:26:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-07 19:26:04 -0400 |
commit | 5c8086741e14a35c98d230b1ba0967073764218b (patch) | |
tree | afe10d995c538bcb665652eb549abb522338cd72 | |
parent | 8ff38bc0b8cd98fd63fbdcc7035852e2ff2e20d2 (diff) | |
parent | 7df226f11b571b9f67a73407624f303006e81f5f (diff) | |
download | numpy-5c8086741e14a35c98d230b1ba0967073764218b.tar.gz |
Merge pull request #7803 from jzwinck/pep3118-char
BUG: interpret 'c' PEP3118/struct type as 'S1'.
-rw-r--r-- | numpy/core/_internal.py | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 5ad440fa4..85be66d06 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -370,6 +370,7 @@ def _view_is_safe(oldtype, newtype): _pep3118_native_map = { '?': '?', + 'c': 'S1', 'b': 'b', 'B': 'B', 'h': 'h', @@ -396,6 +397,7 @@ _pep3118_native_typechars = ''.join(_pep3118_native_map.keys()) _pep3118_standard_map = { '?': '?', + 'c': 'S1', 'b': 'b', 'B': 'B', 'h': 'i2', diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index ca13a172f..f5991d052 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -5690,6 +5690,12 @@ class TestPEP3118Dtype(object): self._check('(3)T{ix}', ({'f0': ('i', 0), '': (VV(1), 4)}, (3,))) + def test_char_vs_string(self): + dt = np.dtype('c') + self._check('c', dt) + + dt = np.dtype([('f0', 'S1', (4,)), ('f1', 'S4')]) + self._check('4c4s', dt) class TestNewBufferProtocol(object): def _check_roundtrip(self, obj): |