# HG changeset patch # User Neil Blakey-Milner # Date 1331600115 25200 # Node ID 2242a6bc4d527b730589b5a7af94af30baa0e6e2 # Parent 75d3bcd9f2411795800fe14a14d069208f21a7c8 Export numpy.power and a basic test for it diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py --- a/pypy/module/micronumpy/__init__.py +++ b/pypy/module/micronumpy/__init__.py @@ -114,6 +114,7 @@ ('log2', 'log2'), ('log10', 'log10'), ('log1p', 'log1p'), + ('power', 'power'), ]: interpleveldefs[exposed] = "interp_ufuncs.get(space).%s" % impl diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py --- a/pypy/module/micronumpy/test/test_ufuncs.py +++ b/pypy/module/micronumpy/test/test_ufuncs.py @@ -543,3 +543,17 @@ 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]