Skip to content
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

Rewrite interpolation structure to utilize extendible class structure #210

Merged
merged 24 commits into from
Feb 21, 2023

Conversation

RuneDominik
Copy link
Member

While the current structure of pyirfs interpolation functionalities might suffice with only few interpolation algorithms implemented, extending it with further algorithms (e.g. Moment-Morphing and extrapolation) would result in at least some I/O-Code doubling. This PR refactors the current interpolation algorithms into a class-structure with the upside of having:

  • Somewhat defined in- and output so algorithms can simply be exchanged
  • Predefined data sanity-checks (e.g. not each interpolation method has to check if the target-point lies within the grid)
  • Predefined "interface" to use future extrapolators

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Base: 90.71% // Head: 92.43% // Increases project coverage by +1.72% 🎉

Coverage data is based on head (e2af267) compared to base (a3e810b).
Patch coverage: 99.22% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #210      +/-   ##
==========================================
+ Coverage   90.71%   92.43%   +1.72%     
==========================================
  Files          42       49       +7     
  Lines        1723     1996     +273     
==========================================
+ Hits         1563     1845     +282     
+ Misses        160      151       -9     
Impacted Files Coverage Δ
...irf/interpolation/tests/test_base_interpolators.py 98.29% <98.29%> (ø)
pyirf/interpolation/base_interpolators.py 98.52% <98.52%> (ø)
pyirf/interpolation/__init__.py 100.00% <100.00%> (ø)
pyirf/interpolation/griddata_interpolator.py 100.00% <100.00%> (ø)
pyirf/interpolation/interpolate_irfs.py 100.00% <100.00%> (ø)
pyirf/interpolation/quantile_interpolator.py 100.00% <100.00%> (ø)
.../interpolation/tests/test_griddata_interpolator.py 100.00% <100.00%> (ø)
pyirf/interpolation/tests/test_interpolate_irfs.py 100.00% <100.00%> (ø)
.../interpolation/tests/test_quantile_interpolator.py 100.00% <100.00%> (ø)
pyirf/conftest.py 93.75% <0.00%> (+43.75%) ⬆️

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

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@RuneDominik RuneDominik force-pushed the rewrite_interpolation_structure branch 2 times, most recently from 8f0819c to afaf775 Compare February 7, 2023 14:45
@RuneDominik RuneDominik force-pushed the rewrite_interpolation_structure branch from c46841e to a84ca37 Compare February 9, 2023 11:29
Copy link
Member

@maxnoe maxnoe left a comment

Choose a reason for hiding this comment

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

Looks mostly good, some comments inline.

Due to the changes, the top-level API (the functions in interpolate.py) now seem all untested, which is not good, that should be fixed.

@RuneDominik RuneDominik force-pushed the rewrite_interpolation_structure branch from a84ca37 to 4c55923 Compare February 15, 2023 09:37
@RuneDominik RuneDominik force-pushed the rewrite_interpolation_structure branch from 11ec002 to 062e3ac Compare February 17, 2023 14:06
Copy link
Member

@maxnoe maxnoe left a comment

Choose a reason for hiding this comment

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

The only thing I don't quite like yet is the structure. Having submodules interpolation and interpolators right next to each other is confusing.

I'd create a single submodule interpolation (directory) and move the interpolation.py to something like interpolation/interpolate_irfs.py and then import those and the other classes in interpolation/__init__.py, that way, the imports also stay backwards compatible with what is currently in interpolation.py.

docs/interpolation.rst Outdated Show resolved Hide resolved
of interpolation algorithms as interpolators as well as scripts applying those to
IRF components.
conditions to a new IRF. Implementations of interpolation algorithms exist as interpolator
objects and are applied by top-level scripts to IRF components.
Copy link
Member

Choose a reason for hiding this comment

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

objects → classes, scripts → functions?

Simple wrapper around scipy.interpolate.griddata to interpolate parametrized quantities
"""

import numpy as np
Copy link
Member

Choose a reason for hiding this comment

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

unused import

@maxnoe maxnoe merged commit 7c31b94 into master Feb 21, 2023
@maxnoe maxnoe deleted the rewrite_interpolation_structure branch February 21, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants