diff options
author | Allan Haldane <allan.haldane@gmail.com> | 2015-07-19 20:55:34 -0400 |
---|---|---|
committer | Allan Haldane <allan.haldane@gmail.com> | 2015-07-20 18:10:58 -0400 |
commit | b68a522e9e3a7d04edf79ffa24c6637dcaaf8786 (patch) | |
tree | 16b3a3b128d95e03b952934468e79de6a68f29c4 /numpy/core | |
parent | cc7e908ab1909aa7911601ed2a245111b0801d79 (diff) | |
download | numpy-b68a522e9e3a7d04edf79ffa24c6637dcaaf8786.tar.gz |
MAINT: allow '?' in structured dtype commastring specification
Code like `dtype('?,?,?')` now works.
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/_internal.py | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_dtype.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index f8271d5ab..bf492d105 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -138,7 +138,7 @@ format_re = re.compile(asbytes( r'(?P<order1>[<>|=]?)' r'(?P<repeats> *[(]?[ ,0-9L]*[)]? *)' r'(?P<order2>[<>|=]?)' - r'(?P<dtype>[A-Za-z0-9.]*(?:\[[a-zA-Z0-9,.]+\])?)')) + r'(?P<dtype>[A-Za-z0-9.?]*(?:\[[a-zA-Z0-9,.]+\])?)')) sep_re = re.compile(asbytes(r'\s*,\s*')) space_re = re.compile(asbytes(r'\s+$')) diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index b293cdbbc..44a086ce1 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -252,6 +252,12 @@ class TestRecord(TestCase): dt2 = np.dtype((np.void, dt.fields)) assert_equal(dt2.fields, dt.fields) + def test_bool_commastring(self): + d = np.dtype('?,?,?') # raises? + assert_equal(len(d.names), 3) + for n in d.names: + assert_equal(d.fields[n][0], np.dtype('?')) + class TestSubarray(TestCase): def test_single_subarray(self): |