[pypy-commit] pypy default: test/fix buffer(numpy.scalar)
bdkearns
noreply at buildbot.pypy.org
Wed Dec 18 03:20:36 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r68456:2ec4090a85d4
Date: 2013-12-17 21:17 -0500
http://bitbucket.org/pypy/pypy/changeset/2ec4090a85d4/
Log: test/fix buffer(numpy.scalar)
diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -313,6 +313,9 @@
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:
@@ -518,6 +521,7 @@
__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),
diff --git a/pypy/module/micronumpy/test/test_scalar.py b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -92,6 +92,15 @@
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_
More information about the pypy-commit
mailing list