Commits

Brian Kearns  committed 2ec4090

test/fix buffer(numpy.scalar)

  • Participants
  • Parent commits 2e0e9bf

Comments (0)

Files changed (2)

File pypy/module/micronumpy/interp_boxes.py

     def descr_copy(self, space):
         return self.convert_to(space, self.get_dtype(space))
 
+    def descr_buffer(self, space):
+        return self.descr_ravel(space).descr_get_data(space)
+
     w_flags = None
     def descr_get_flags(self, space):
         if self.w_flags is None:
     __nonzero__ = interp2app(W_GenericBox.descr_nonzero),
     __oct__ = interp2app(W_GenericBox.descr_oct),
     __hex__ = interp2app(W_GenericBox.descr_hex),
+    __buffer__ = interp2app(W_GenericBox.descr_buffer),
 
     __add__ = interp2app(W_GenericBox.descr_add),
     __sub__ = interp2app(W_GenericBox.descr_sub),

File pypy/module/micronumpy/test/test_scalar.py

         assert b == a
         assert b is not a
 
+    def test_buffer(self):
+        import numpy as np
+        a = np.int32(123)
+        b = buffer(a)
+        assert type(b) is buffer
+        a = np.string_('abc')
+        b = buffer(a)
+        assert str(b) == a
+
     def test_squeeze(self):
         import numpy as np
         assert np.True_.squeeze() is np.True_