[pypy-issue] [issue1129] numpypy reduce methods don't work with scalars

mikefc tracker at bugs.pypy.org
Sat Apr 14 14:12:19 CEST 2012


New submission from mikefc <coolbutuseless at gmail.com>:

Found this bug while looking at numpy/lib/financial.py definition of rate() method.

It seems that the reduce_ufunc_impls in numpypy (any, all, min, max etc) don't work with 
scalars, but they do in numpy.


=================================
python
Python 2.7.2 (default, Feb  2 2012, 22:10:10) 
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.all(1)
True
>>> np.any(1)
True
>>> np.min(1)
1
>>> np.sum(1)
1


===============================
~/pypy-latest/bin/pypy 
Python 2.7.2 (1da1c1632353, Apr 13 2012, 01:00:24)
[PyPy 1.9.1-dev0 with GCC 4.2.1] on darwin
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``The migration to mercurial is
completed! http://bitbucket.org/pypy/pypy''
>>>> import numpypy as np
>>>> np.all(1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/mike/pypy-latest/lib_pypy/numpypy/core/fromnumeric.py", line 1545, in all
    return a.all()
TypeError: cannot reduce on a scalar
>>>> np.any(1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/mike/pypy-latest/lib_pypy/numpypy/core/fromnumeric.py", line 1481, in any
    return a.any()
TypeError: cannot reduce on a scalar
>>>> np.min(1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: cannot reduce on a scalar
>>>> np.sum(1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/mike/pypy-latest/lib_pypy/numpypy/core/fromnumeric.py", line 1365, in sum
    return a.sum(axis=axis)
TypeError: cannot reduce on a scalar

----------
messages: 4260
nosy: mikefc, pypy-issue
priority: bug
status: unread
title: numpypy reduce methods don't work with scalars

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1129>
________________________________________


More information about the pypy-issue mailing list