Commits

Neil Blakey-Milner committed 2242a6b

Export numpy.power and a basic test for it

Comments (0)

Files changed (2)

pypy/module/micronumpy/__init__.py

         ('log2', 'log2'),
         ('log10', 'log10'),
         ('log1p', 'log1p'),
+        ('power', 'power'),
     ]:
         interpleveldefs[exposed] = "interp_ufuncs.get(space).%s" % impl
 

pypy/module/micronumpy/test/test_ufuncs.py

             assert log1p(v) == float("-inf")
         assert log1p(float('inf')) == float('inf')
         assert (log1p([0, 1e-50, math.e - 1]) == [0, 1e-50, 1]).all()
+
+    def test_power(self):
+        import math
+        from _numpypy import power, array
+        a = array([1., 2., 3.])
+        b = power(a, 3)
+        for i in range(len(a)):
+            assert b[i] == a[i] ** 3
+
+        a = array([1., 2., 3.])
+        b = array([1., 2., 3.])
+        c = power(a, b)
+        for i in range(len(a)):
+            assert c[i] == a[i] ** b[i]