[pypy-commit] pypy default: provide additional scalar methods

bdkearns noreply at buildbot.pypy.org
Fri Jan 31 01:15:38 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r69028:1ae08cdaa8dc
Date: 2014-01-30 19:14 -0500
http://bitbucket.org/pypy/pypy/changeset/1ae08cdaa8dc/

Log:	provide additional scalar methods

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
@@ -586,6 +586,10 @@
     __hash__ = interp2app(W_GenericBox.descr_hash),
 
     tolist = interp2app(W_GenericBox.item),
+    min = interp2app(W_GenericBox.descr_self),
+    max = interp2app(W_GenericBox.descr_self),
+    sum = interp2app(W_GenericBox.descr_self),
+    prod = interp2app(W_GenericBox.descr_self),
     any = interp2app(W_GenericBox.descr_any),
     all = interp2app(W_GenericBox.descr_all),
     ravel = interp2app(W_GenericBox.descr_ravel),
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
@@ -102,6 +102,12 @@
         assert b == a
         assert b is not a
 
+    def test_methods(self):
+        import numpy as np
+        for a in [np.int32(2), np.float64(2.0), np.complex64(42)]:
+            for op in ['min', 'max', 'sum', 'prod']:
+                assert getattr(a, op)() == a
+
     def test_buffer(self):
         import numpy as np
         a = np.int32(123)


More information about the pypy-commit mailing list