[Numpy-discussion] Bug in numpy.fix(): broken for scalar arguments
Darren Dale
dsdale24 at gmail.com
Sun Apr 18 09:28:02 EDT 2010
On Sun, Apr 18, 2010 at 9:08 AM, Darren Dale <dsdale24 at gmail.com> wrote:
> On Sat, Apr 17, 2010 at 4:16 PM, Charles R Harris
> <charlesr.harris at gmail.com> wrote:
>>
>>
>> On Sat, Apr 17, 2010 at 2:01 PM, Eric Firing <efiring at hawaii.edu> wrote:
>>>
>>> np.fix() no longer works for scalar arguments:
>>>
>>>
>>> In [1]:import numpy as np
>>>
>>> In [2]:np.version.version
>>> Out[2]:'2.0.0.dev8334'
>>>
>>> In [3]:np.fix(3.14)
>>>
>>> ---------------------------------------------------------------------------
>>> TypeError Traceback (most recent call
>>> last)
>>>
>>> /home/efiring/<ipython console> in <module>()
>>>
>>> /usr/local/lib/python2.6/dist-packages/numpy/lib/ufunclike.pyc in fix(x,
>>> y)
>>> 46 if y is None:
>>> 47 y = y1
>>> ---> 48 y[...] = nx.where(x >= 0, y1, y2)
>>> 49 return y
>>> 50
>>>
>>> TypeError: 'numpy.float64' object does not support item assignment
>>>
>>>
>>
>> Looks like r8293. Darren?
>
> Thanks, I'm looking into it.
The old np.fix behavior is different from np.floor and np.ceil.
np.fix(3.14) would return array(3.0), while np.floor(3.14) would
return 3.0. Shall I fix it to conform with the old but inconsistent
behavior of fix?
Darren
More information about the NumPy-Discussion
mailing list