[pypy-commit] pypy default: support numpy.dtype('a#')

bdkearns noreply at buildbot.pypy.org
Thu May 1 06:05:21 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r71115:d76f8f5ea228
Date: 2014-04-30 23:17 -0400
http://bitbucket.org/pypy/pypy/changeset/d76f8f5ea228/

Log:	support numpy.dtype('a#')

diff --git a/pypy/module/micronumpy/descriptor.py b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -526,7 +526,7 @@
             if name[0] == NPY.OPPBYTE:
                 dtype = dtype.descr_newbyteorder(space)
             return dtype
-        if name[0] in 'VSUc' or name[0] in '<>=|' and name[1] in 'VSUc':
+        if name[0] in 'VSUca' or name[0] in '<>=|' and name[1] in 'VSUca':
             return variable_dtype(space, name)
         raise oefmt(space.w_TypeError, 'data type "%s" not understood', name)
     elif space.isinstance_w(w_dtype, space.w_list):
@@ -607,7 +607,7 @@
             raise oefmt(space.w_TypeError, "data type not understood")
     if char == NPY.CHARLTR:
         return new_string_dtype(space, 1, NPY.CHARLTR)
-    elif char == NPY.STRINGLTR:
+    elif char == NPY.STRINGLTR or char == NPY.STRINGLTR2:
         return new_string_dtype(space, size)
     elif char == NPY.UNICODELTR:
         return new_unicode_dtype(space, size)
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -191,6 +191,9 @@
         d = dtype('S5')
         assert repr(d) == "dtype('S5')"
         assert str(d) == "|S5"
+        d = dtype('a5')
+        assert repr(d) == "dtype('S5')"
+        assert str(d) == "|S5"
         d = dtype('U5')
         assert repr(d) == "dtype('%sU5')" % b
         assert str(d) == "%sU5" % b


More information about the pypy-commit mailing list