[pypy-commit] pypy default: merge heads
arigo
noreply at buildbot.pypy.org
Mon Dec 12 19:17:50 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r50440:c805becb84aa
Date: 2011-12-12 19:17 +0100
http://bitbucket.org/pypy/pypy/changeset/c805becb84aa/
Log: merge heads
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
@@ -79,8 +79,12 @@
appleveldefs = {
'average': 'app_numpy.average',
'mean': 'app_numpy.mean',
+ 'sum': 'app_numpy.sum',
+ 'min': 'app_numpy.min',
+ 'max': 'app_numpy.max',
'inf': 'app_numpy.inf',
'e': 'app_numpy.e',
+ 'pi': 'app_numpy.pi',
'arange': 'app_numpy.arange',
'reshape': 'app_numpy.reshape',
}
diff --git a/pypy/module/micronumpy/app_numpy.py b/pypy/module/micronumpy/app_numpy.py
--- a/pypy/module/micronumpy/app_numpy.py
+++ b/pypy/module/micronumpy/app_numpy.py
@@ -5,6 +5,7 @@
inf = float("inf")
e = math.e
+pi = math.pi
def average(a):
@@ -18,6 +19,20 @@
a = numpypy.array(a)
return a.mean()
+def sum(a):
+ if not hasattr(a, "sum"):
+ a = numpypy.array(a)
+ return a.sum()
+
+def min(a):
+ if not hasattr(a, "min"):
+ a = numpypy.array(a)
+ return a.min()
+
+def max(a):
+ if not hasattr(a, "max"):
+ a = numpypy.array(a)
+ return a.max()
def arange(start, stop=None, step=1, dtype=None):
'''arange([start], stop[, step], dtype=None)
diff --git a/pypy/module/micronumpy/test/test_module.py b/pypy/module/micronumpy/test/test_module.py
--- a/pypy/module/micronumpy/test/test_module.py
+++ b/pypy/module/micronumpy/test/test_module.py
@@ -11,11 +11,28 @@
from numpypy import array, average
assert average(range(10)) == 4.5
assert average(array(range(10))) == 4.5
+
+ def test_sum(self):
+ from numpypy import array, sum
+ assert sum(range(10)) == 45
+ assert sum(array(range(10))) == 45
+
+ def test_min(self):
+ from numpypy import array, min
+ assert min(range(10)) == 0
+ assert min(array(range(10))) == 0
+
+ def test_max(self):
+ from numpypy import array, max
+ assert max(range(10)) == 9
+ assert max(array(range(10))) == 9
def test_constants(self):
import math
- from numpypy import inf, e
+ from numpypy import inf, e, pi
assert type(inf) is float
assert inf == float("inf")
assert e == math.e
assert type(e) is float
+ assert pi == math.pi
+ assert type(pi) is float
diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -250,22 +250,6 @@
'int_ge': 1, 'guard_false': 1,
'jump': 1})
- def define_slice2():
- return """
- a = |30|
- s1 = a -> :20:2
- s2 = a -> :30:3
- b = s1 + s2
- b -> 3
- """
-
- def test_slice2(self):
- result = self.run("slice2")
- assert result == 15
- self.check_simple_loop({'getinteriorfield_raw': 2, 'float_add': 1,
- 'setinteriorfield_raw': 1, 'int_add': 3,
- 'int_ge': 1, 'guard_false': 1, 'jump': 1})
-
def define_multidim():
return """
a = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
More information about the pypy-commit
mailing list