Run black on utils/interpolation.py
@@ -7,18 +7,22 @@ import numpy as np
class ScaledRegularGridInterpolator(object):
"""Thin wrapper around `scipy.interpolate.RegularGridInterpolator`.
+ The values are scaled before the interpolation and back-scaled after the
+ interpolation.
+
Parameters
----------
points : tuple
Tuple of points passed to `RegularGridInterpolator`.
values :
Values passed to `RegularGridInterpolator`.
- values_scale : {'log', 'lin', 'sqrt'}
+ values_scale : {'lin', 'log', 'sqrt'}
Interpolation scaling applied to values. If the values vary over many magnitudes
a 'log' scaling is recommended.
**kwargs : dict
Keyword arguments passed to `RegularGridInterpolator`.
"""
+
# TODO: add points scaling or axis scaling argument
def __init__(self, points, values, values_scale="lin", extrapolate=True, **kwargs):
from scipy.interpolate import RegularGridInterpolator
@@ -31,9 +35,7 @@ class ScaledRegularGridInterpolator(object):
kwargs.setdefault("fill_value", None)
self._interpolate = RegularGridInterpolator(
- points=points,
- values=values_scaled,
- **kwargs
+ points=points, values=values_scaled, **kwargs
)
def __call__(self, points, method="linear", clip=True, **kwargs):
@@ -71,6 +73,7 @@ def interpolation_scale(scale="lin"):
class LogScaling(object):
"""Logarithmic scaling"""
+
def __call__(self, values):
tiny = np.finfo(values.dtype).tiny
values = np.clip(values, tiny, np.inf)
@@ -82,6 +85,7 @@ class LogScaling(object):
class SqrtScaling(object):
"""Sqrt scaling"""
+
def __call__(self, values):
values = np.clip(values, 0, np.inf)
return np.sqrt(values)
@@ -92,6 +96,7 @@ class SqrtScaling(object):
class LinearScaling(object):
"""Linear scaling"""
+
def __call__(self, values):
return values
