Skip to content

Implement Akima1DInterpolator #12833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Implement Akima1DInterpolator #12833

wants to merge 1 commit into from

Conversation

gliptak
Copy link
Contributor

@gliptak gliptak commented Apr 9, 2016

@gliptak
Copy link
Contributor Author

gliptak commented Apr 9, 2016

This build failed https://travis-ci.org/pydata/pandas/jobs/121843938 likely because of the Scipy version.

axis was added to Akima1DInterpolator at 0.17.0 as per scipy/scipy@b0395b4

Is there a minimum version of Scipy for pandas? What would be a good way to handle lower versions?

Thanks

50.75]))
interp_s = ser.reindex(new_index).interpolate(method='akima')
# does not blow up, GH5977
interp_s[49:51]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls have an expected case and use assert_series_equal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added assert

@jreback jreback added Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Apr 9, 2016
@jreback
Copy link
Contributor

jreback commented Apr 9, 2016

you can you call this in a try: except to handle the scipy signature differences. (then if it doesn't work in the excpet, raise again). we don't have a min version.

try:
P = interpolate.Akima1DInterpolator(xi, yi, axis=axis)
except TypeError:
# Scipy earlier than 0.17.0 missing axis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so need a test for this. on the 2.7_LOCALE build we install a really old scipy. We may need to install a somewhat newer one on another build to explicity test for this. When did this Akima1DInterpolate appear in scipy? and seems the axis parm was added in 0.17.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.14.0 (as per scipy/scipy@a0a3b38) I implemented a different check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok the 3.4 build has scipy==0.14.0 installed so pls verify that the test works corretctly (IOW it is NOT skipped, but passes).

remove scipy from ci/requirements-3.5_OSX. Make sure that you DO see some skips. I don't think we were testing having NO scipy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok , just remove scipy from ci/requirements-3.5_OSX and I think will be good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from ci/requirements-3.5_OSX.run ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep (we are including a version of scipy on EVERY build, so need to take it from one)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@gliptak
Copy link
Contributor Author

gliptak commented Apr 9, 2016

The two test failures seem to be unrelated.

1 similar comment
@gliptak
Copy link
Contributor Author

gliptak commented Apr 10, 2016

The two test failures seem to be unrelated.

"PCHIP interpolation.")

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change this (and the pchip one to something like):

if method == 'akima':
    alt_methods['akima'] = _akima_interpolate

Move to _akima_interpolate

    from scipy.interpolate import Akima1DInterpolator  # noqa

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@jreback
Copy link
Contributor

jreback commented Apr 10, 2016

pls add a whatsnew as well

@gliptak
Copy link
Contributor Author

gliptak commented Apr 10, 2016

Added whatsnew

except ImportError:
if method == 'akima':
if method == 'akima':
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is fine

@jreback
Copy link
Contributor

jreback commented Apr 10, 2016

pls squash

@jreback
Copy link
Contributor

jreback commented Apr 10, 2016

add a small note when to use this in : http://pandas-docs.github.io/pandas-docs-travis/missing_data.html#interpolation (you might want to break up that section a bit and make it into a table)

@jreback
Copy link
Contributor

jreback commented Apr 10, 2016

add to the doc-string for .interpolate with a versionadded tag

@gliptak
Copy link
Contributor Author

gliptak commented Apr 10, 2016

Added notes and versionadded tag

@@ -101,6 +101,7 @@ def interpolate_1d(xvalues, yvalues, method='linear', limit=None,

Bounds_error is currently hardcoded to False since non-scipy ones don't
take it as an argumnet.
.. versionadded:: 0.18.1 support for 'akima'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no this needs to be updated in pandas.core.generic.NDFrame.interpolate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved section.

@gliptak
Copy link
Contributor Author

gliptak commented Apr 10, 2016

Updated per comments.


* If you are dealing with a time series that is growing at an increasing rate,
``method='quadratic'`` may be appropriate.
* If you have values approximating a cumulative distribution function,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

@jreback jreback added this to the 0.18.1 milestone Apr 10, 2016
@jreback
Copy link
Contributor

jreback commented Apr 10, 2016

ok, looks good. ping when green (and pls verify that tests are skipped as appropriate)

distribution function, then ``method='pchip'`` should work well.

* If you are dealing with a time series that is growing at an increasing rate,
``method='quadratic'`` may be appropriate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need two spaces here at the beginning of this line, so the start of the text is aligned with the start of the text in the previous line ('If ...')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

wrappers around the scipy interpolation methods of similar
names. These use the actual numerical values of the index. See
the scipy documentation for more on their behavior
`here <http://docs.scipy.org/doc/scipy/reference/interpolate.html#univariate-interpolation>`__ # noqa
`and here <http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html>`__ # noqa

.. versionadded:: 0.18.1 support for 'akima'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'support for 'akima'' should go on the next line I think. See the sphinx docs: http://www.sphinx-doc.org/en/stable/markup/para.html#directive-versionadded for an example. And then maybe change the text to something like "Added support for the 'akima' method"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@jorisvandenbossche
Copy link
Member

@gliptak I just added some more doc comments, looks very good for the rest!

@gliptak
Copy link
Contributor Author

gliptak commented Apr 11, 2016

@jreback Build is green. Tests skipped https://s3.amazonaws.com/archive.travis-ci.org/jobs/122101334/log.txt

#268 pandas.tests.test_generic.TestSeries.test_interpolate_akima: no scipy.stats module
#269 pandas.tests.test_generic.TestSeries.test_interpolate_corners: no scipy.stats module
#270 pandas.tests.test_generic.TestSeries.test_interpolate_pchip: no scipy.stats module

I also opened #12856 (consistently fails the same way)

@jreback jreback closed this in 1c8816f Apr 11, 2016
@jreback
Copy link
Contributor

jreback commented Apr 11, 2016

@gliptak thanks!

pls review the built docs for accuracy (and good looking ness) and issue a follow up if necessary. (prob will take a few hours before they are built)

@gliptak
Copy link
Contributor Author

gliptak commented Apr 11, 2016

@jreback @jorisvandenbossche Thank you for guiding this through

@gliptak
Copy link
Contributor Author

gliptak commented Apr 11, 2016

Docs updated good.

@gliptak gliptak deleted the akima branch April 12, 2016 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Akima Interpolation to Pandas
3 participants