Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Oct 11, 2022
1 parent bc4ae6a commit 3c9d902
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions adaptive/learner/learner2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from adaptive.learner.base_learner import BaseLearner
from adaptive.learner.triangulation import simplex_volume_in_embedding
from adaptive.notebook_integration import ensure_holoviews
from adaptive.types import Bool
from adaptive.utils import (
assign_defaults,
cache_latest,
Expand Down Expand Up @@ -530,7 +531,9 @@ def bounds_are_done(self) -> bool:
(p in self.pending_points or p in self._stack) for p in self._bounds_points
)

def interpolated_on_grid(self, n=None):
def interpolated_on_grid(
self, n: int = None
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
"""Get the interpolated data on a grid.
Parameters
Expand Down Expand Up @@ -593,7 +596,7 @@ def _data_combined(self) -> tuple[np.ndarray, np.ndarray]:
values_combined = np.vstack([values, values_interp])
return points_combined, values_combined

def ip(self):
def ip(self) -> LinearNDInterpolator:
"""Deprecated, use `self.interpolator(scaled=True)`"""
warnings.warn(
"`learner.ip()` is deprecated, use `learner.interpolator(scaled=True)`."
Expand Down Expand Up @@ -643,7 +646,7 @@ def _interpolator_combined(self) -> LinearNDInterpolator:
self._ip_combined = interpolate.LinearNDInterpolator(points, values)
return self._ip_combined

def inside_bounds(self, xy: tuple[float, float]) -> bool | np.bool_:
def inside_bounds(self, xy: tuple[float, float]) -> Bool:
x, y = xy
(xmin, xmax), (ymin, ymax) = self.bounds
return xmin <= x <= xmax and ymin <= y <= ymax
Expand Down
3 changes: 2 additions & 1 deletion adaptive/learner/learnerND.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
simplex_volume_in_embedding,
)
from adaptive.notebook_integration import ensure_holoviews, ensure_plotly
from adaptive.types import Bool
from adaptive.utils import (
assign_defaults,
cache_latest,
Expand Down Expand Up @@ -574,7 +575,7 @@ def _simplex_exists(self, simplex: Simplex) -> bool:
simplex = tuple(sorted(simplex))
return simplex in self.tri.simplices

def inside_bounds(self, point: tuple[float, ...]) -> bool | np.bool_:
def inside_bounds(self, point: tuple[float, ...]) -> Bool:
"""Check whether a point is inside the bounds."""
if self._interior is not None:
return self._interior.find_simplex(point, tol=1e-8) >= 0
Expand Down

0 comments on commit 3c9d902

Please sign in to comment.