Jeff Terrace avatar Jeff Terrace committed d4d7f06

Added pi, sum, min, and max

Comments (0)

Files changed (3)


     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',


 inf = float("inf")
 e = math.e
+pi = math.pi
 def average(a):
         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)


         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.