Skip to content

Commit 8d4263a

Browse files
authored
Fix NaN issue for Learner1D R -> R^n (#340)
If a function evaluates over a point where it is not defined, NaN will be returned. In the case of a function R -> R^n, it caused `_update_scale` to compute `self._scale[1] = nan`, which in turns led to the evaluation of the function on all other points to be NaN, causing an infinite loop, as reported in issue #339. Using `np.nanmin` and `np.nanmax` in place of `np.min` and `np.max` seems to solve the issue.
1 parent ef3b1c5 commit 8d4263a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

adaptive/learner/learner1D.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ def _update_scale(self, x: float, y: Union[Float, np.ndarray]) -> None:
464464
if y is not None:
465465
if self.vdim > 1:
466466
try:
467-
y_min = np.min([self._bbox[1][0], y], axis=0)
468-
y_max = np.max([self._bbox[1][1], y], axis=0)
467+
y_min = np.nanmin([self._bbox[1][0], y], axis=0)
468+
y_max = np.nanmax([self._bbox[1][1], y], axis=0)
469469
except ValueError:
470470
# Happens when `_bbox[1]` is a float and `y` a vector.
471471
y_min = y_max = y

0 commit comments

Comments
 (0)