EconForge / interpolation.py

BSD 2-Clause "Simplified" License
123 stars 35 forks source link

Stability issues #32

Closed natashawatkins closed 5 years ago

natashawatkins commented 5 years ago

Currently trying to switch np.interp to interp, and running into some stability issues - sometimes it works but sometimes I run into this error and my code won't work

screen shot 2018-10-02 at 12 05 29 pm
albop commented 5 years ago

That looks suspiciously like the bug related to extrapolation that I fixed recently. Which version are you running ?

albop commented 5 years ago

If the problem is not with library version this issue is a bit hard for me to address as I have no idea what triggers the faulty behaviour. I would need a reduced example or at least some code that I can run.

natashawatkins commented 5 years ago

I believe I updated to 2.0.1

albop commented 5 years ago

Are you sure you deinstalled any pip version you might have had on your computer?

On Tue, Oct 2, 2018 at 7:23 PM Natasha notifications@github.com wrote:

I believe I updated to 2.0.1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EconForge/interpolation.py/issues/32#issuecomment-426359329, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ5KQ0ay2I5ksrAbMvLK9AktmxXmGglks5ug6EdgaJpZM4XEaqR .

natashawatkins commented 5 years ago

Yep I just uninstalled and then reinstalled and I'm still having issues

albop commented 5 years ago

I can't replicate it on my computers. Could you do the following please ?

natashawatkins commented 5 years ago

Do you mean pip install interpolation? I'm almost very sure I have 2.0.1 installed. It only occurs with this specific piece of code I'm using

natashawatkins commented 5 years ago

Here is the issue again after reinstalling: image

albop commented 5 years ago

No, I mean pip uninstall .... Sometimes an old pip version can cohabitate with the conda version.

albop commented 5 years ago

hmm, I don't see the issue ;-)

natashawatkins commented 5 years ago

I did pip uninstall but I couldn't find the conda package? Am I meant to have a channel configured or something?

albop commented 5 years ago

sorry, should have specified it: conda install -c conda-forge interpolation

On Wed, Oct 3, 2018 at 9:43 AM Natasha notifications@github.com wrote:

I did pip uninstall but I couldn't find the conda package? Am I meant to have a channel configured or something?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EconForge/interpolation.py/issues/32#issuecomment-426541839, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ5KX39D0HJVBFZVVLF1-XMAGFmCrZjks5uhGqigaJpZM4XEaqR .

natashawatkins commented 5 years ago

Ok I installed via conda-forge and still got the same error

image

albop commented 5 years ago

Thank you @natashawatkins . But in order to understand the problem, I need to see the code where the function interp is being called. This is not apparent in the example you supply. Can you point me to the source ?

natashawatkins commented 5 years ago

In this notebook here: https://github.com/jstac/jitting_py_lectures/blob/master/lucas_model.ipynb

albop commented 5 years ago

Thanks, let me have a look.

albop commented 5 years ago

So this comes from the extrapolation behaviour of np.interp and interpolation.interp. The former uses a constant equal to the nearest value on the grid, while the latter extrapolates linearly (see graph). Apparently this causes the convergence failure of the iterations, maybe by causing negative values. extrapolation

There are plans for a flexible extrapolation system, but in the meantime I'll commit a small change so that interp works with constant extrapolation and matches better default options of np.interp

natashawatkins commented 5 years ago

Thanks!!