diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-08-03 12:27:54 -0500 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-27 07:26:51 -0600 |
commit | 0e5fb25980859a44fed8a1b5ddc85075d28c7883 (patch) | |
tree | 6ff12a4267493fb8e2b6702ebaa6872671b55819 /numpy/core/fromnumeric.py | |
parent | b471b5aace551d294f2ffe4f7be569fd6f148f50 (diff) | |
download | numpy-0e5fb25980859a44fed8a1b5ddc85075d28c7883.tar.gz |
ENH: missingdata: Change things to help scipy pass its tests
Improving the NumPy tests a bit to catch these errors better...
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index f102f4b58..c7e390c73 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1455,7 +1455,14 @@ def sum(a, axis=None, dtype=None, out=None): out[...] = res return out return res - return um.add.reduce(a, axis=axis, dtype=dtype, out=out) + elif not (type(a) is mu.ndarray): + try: + sum = a.sum + except AttributeError: + return um.add.reduce(a, axis=axis, dtype=dtype, out=out) + return sum(axis=axis, dtype=dtype, out=out) + else: + return um.add.reduce(a, axis=axis, dtype=dtype, out=out) def product (a, axis=None, dtype=None, out=None): """ @@ -1998,7 +2005,14 @@ def prod(a, axis=None, dtype=None, out=None): True """ - return um.multiply.reduce(a, axis=axis, dtype=dtype, out=out) + if not (type(a) is mu.ndarray): + try: + prod = a.prod + except AttributeError: + return um.multiply.reduce(a, axis=axis, dtype=dtype, out=out) + return prod(axis=axis, dtype=dtype, out=out) + else: + return um.multiply.reduce(a, axis=axis, dtype=dtype, out=out) def cumprod(a, axis=None, dtype=None, out=None): """ |