[Numpy-tickets] [NumPy] #913: max is bogus if nan is in the array
NumPy
numpy-tickets@scipy....
Sun Sep 21 04:30:41 CDT 2008
#913: max is bogus if nan is in the array
--------------------+-------------------------------------------------------
Reporter: cdavid | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.2.1
Component: Other | Version: none
Severity: major | Resolution:
Keywords: |
--------------------+-------------------------------------------------------
Comment (by cdavid):
I attached a patch to handle those cases: the ufunc now put Nan in the
output whenver NaN is encountered in any input. So in both cases (#913 and
#914), the answer is now nan.
Depending on the platform, the slowdown is significant for big (~1e5/1e6)
arraygs:
- 3x: linux 32 bits, P4, ubuntu gcc 4.2.3, glibc isnan
- negligeable (Mac OS X; Linux 64 bits, Core 2 duo).
I would think that the Pentium 4 is pathological, and that in most cases,
the slowdown is limited. My computer with the P4 has a really peculiar
FPU. I used this simple script for benchmark:
{{{
#!python
from timeit import Timer
import numpy as np
print np.version.version
print np.__file__
a = np.array([5, 2, np.nan, -1, 2])
b = np.array([5, 2, -1, 2, np.nan])
print np.max(a)
print np.max(b)
setup = '''
import numpy as np
tests = [np.random.randn(2**n) for n in range(20)]
'''
timers = [Timer('np.max(tests[%d])' % i, setup=setup) for i in range(20)]
for i in timers:
print i.repeat(3, number=100)[0] / 100
}}}
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/913#comment:1>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list