Commits

Romain Guillebert committed 36f863c

Make numpy.character usable as a dtype (it's an alias for str)

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_dtype.py

             name='string',
             char='S',
             w_box_type = space.gettypefor(interp_boxes.W_StringBox),
-            alternate_constructors=[space.w_str],
+            alternate_constructors=[space.w_str, space.gettypefor(interp_boxes.W_CharacterBox)],
             aliases=["str"],
         )
         self.w_unicodedtype = W_Dtype(

pypy/module/micronumpy/test/test_dtypes.py

     def test_character_dtype(self):
         from numpypy import array, character
         x = array([["A", "B"], ["C", "D"]], character)
-        assert x == [["A", "B"], ["C", "D"]]
+        assert (x == [["A", "B"], ["C", "D"]]).all()
 
 class AppTestRecordDtypes(BaseNumpyAppTest):
     spaceconfig = dict(usemodules=["micronumpy", "struct", "binascii"])