Skip to content

#2229 default linear interp - #2258

Merged
rtimms merged 3 commits into
developfrom
issue-2229-linear-interp
Sep 13, 2022
Merged

#2229 default linear interp#2258
rtimms merged 3 commits into
developfrom
issue-2229-linear-interp

Conversation

@rtimms

@rtimms rtimms commented Aug 24, 2022

Copy link
Copy Markdown
Contributor

Description

Make the default interpolator linear.

Fixes #2229 #2017

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@valentinsulzer valentinsulzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is "cubic" better than "cubic spline"? Cubic spline is used by scipy https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicSpline.html

@rtimms

rtimms commented Aug 24, 2022

Copy link
Copy Markdown
Contributor Author

I originally changed it as I was going to just pass kind=interpolator to interp1d, but you couldn't take the derivative of that so changed back to using CubicSpline. Then I left it as "cubic" for no real reason. You can just pass kind=interpolator to interp2d.

input_data[0],
input_data[-1],
new_children,
interpolator="cubic",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

so the default when creating an interpolant is "linear", but the default when using data is "cubic"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I didn't like doing this. I think it would be better to use "linear" all the time, but you can't take the derivative. We could switch to using InterpolatedUnivariateSpline for the 1D interpolation and just change the degree, then you can, but it's not smooth anyway.

@rtimms rtimms mentioned this pull request Sep 12, 2022
8 tasks
@codecov

codecov Bot commented Sep 12, 2022

Copy link
Copy Markdown

Codecov Report

Merging #2258 (c17c3f9) into develop (b25ce8c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff            @@
##           develop    #2258   +/-   ##
========================================
  Coverage    99.39%   99.39%           
========================================
  Files          364      364           
  Lines        19996    19999    +3     
========================================
+ Hits         19876    19879    +3     
  Misses         120      120           
Impacted Files Coverage Δ
pybamm/parameters/parameter_values.py 99.45% <ø> (ø)
pybamm/expression_tree/interpolant.py 100.00% <100.00%> (ø)
...mm/expression_tree/operations/convert_to_casadi.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@rtimms
rtimms merged commit 669af80 into develop Sep 13, 2022
@rtimms
rtimms deleted the issue-2229-linear-interp branch September 13, 2022 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make default interpolator linear

2 participants