[SciPy-User] Strange behaviour of scipy.interpolate.interp1d in with kind="zero"

Oleksandr Huziy guziy.sasha at gmail.com
Thu Jun 22 13:23:50 EDT 2017


Hi:

I can confirm that the problem disappeared after upgrading scipy to 0.19.0
(numpy got updated as well)

Cheers

2017-06-22 5:23 GMT-04:00 Propadovic Nenad <npropadovic at gmail.com>:

> Hello again,
> OK, the problem went away when I upgraded scipy from 0.18.1 to 0.19.0
> (Anaconda didn't offer 1.0).
> So I guess I have to apologize for bothering.
> Regards,
> Nenad
>
> 2017-06-22 10:45 GMT+02:00 Propadovic Nenad <npropadovic at gmail.com>:
>
>> Hello Evgeni,
>> sorry, somehow initially I had not seen your post.
>> My OS is Windows 7 Professional N 64 bit.
>>
>> Python 2.7.13 |Anaconda 4.3.0 (64-bit)
>> (yes I know Python 3.x is preferred, but that's the company choice that I
>> can't influence... )
>>
>> numpy.__version__
>> Out[2]: '1.11.3'
>>
>> scipy.__version__
>> Out[4]: '0.18.1'
>>
>> Yeah, maybe I can update Anaconda before calling out a bug. But the
>> scipy-version is not soooo old.
>>
>> And, yes, I'm aware of the brittle nature of exact equality of floats...
>> I often use code like following in my unit-tests:
>> assert (numpy.all(abs(x-x_maybe_equal ) < 1e-12))
>>
>> Cheers,
>>
>> Nenad
>>
>>> Cannot repro -- what numpy/scipy versions, OS?
>>>
>>>
>>>
>>> In [2]: %paste
>>> import numpy
>>> from scipy.interpolate import interp1d
>>>
>>> t = numpy.array([0.000, 0.004, 0.008, 0.012, 0.016, 0.02])
>>> sig = numpy.array([0, 1, 2, 3, 4, 5])
>>> t_new = numpy.array([0.0, 0.001, 0.003,  0.004,  0.008, 0.012,  0.016,
>>>  0.0196, 0.02])
>>>
>>> f = interp1d(t, sig, kind='zero')
>>> s_resampled = f(t_new)
>>> print s_resampled
>>> ## -- End pasted text --
>>> [ 0.  0.  0.  1.  2.  3.  4.  4.  5.]
>>>
>>> In [3]: f(t) == sig
>>> Out[3]: array([ True,  True,  True,  True,  True,  True], dtype=bool)
>>>
>>> In [4]: numpy.__version__
>>> Out[4]: '1.10.4'
>>>
>>> In [5]: import scipy
>>>
>>> In [6]: scipy.__version__
>>> Out[6]: '1.0.0.dev0+f3e4e17'
>>>
>>>
>>> Also note that exact equality in floating point is brittle anyway:
>>>
>>> In [9]: f(t_new.astype(numpy.float32))
>>> Out[9]: array([ 0.,  0.,  0.,  1.,  2.,  3.,  4.,  4.,  4.])
>>>
>>> In [10]: f(t_new)
>>> Out[10]: array([ 0.,  0.,  0.,  1.,  2.,  3.,  4.,  4.,  5.])
>>>
>>>
>>> Evgeni
>>>
>>>
>>>
>>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at python.org
> https://mail.python.org/mailman/listinfo/scipy-user
>
>


-- 
Sasha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20170622/02ed6bbe/attachment.html>


More information about the SciPy-User mailing list