Skip to content

Commit 1b421ad

Browse files
committed
2D: do not return points outside the bounds, closes #181
1 parent 142bf49 commit 1b421ad

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

adaptive/learner/learner2D.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,14 @@ def plot(self, n=None, tri_alpha=0):
543543
n = int(0.658 / sqrt(areas(ip).min()))
544544
n = max(n, 10)
545545

546-
x = y = np.linspace(-0.5, 0.5, n)
546+
# The bounds of the linspace should be (-0.5, 0.5) but because of
547+
# numerical precision problems it could (for example) be
548+
# (-0.5000000000000001, 0.49999999999999983), then any point at exact
549+
# boundary would be outside of the domain. See #181.
550+
x_min, y_min = np.min(ip.points, axis=0)
551+
x_max, y_max = np.max(ip.points, axis=0)
552+
x = np.linspace(x_min, x_max, n)
553+
y = np.linspace(y_min, y_max, n)
547554
z = ip(x[:, None], y[None, :] * self.aspect_ratio).squeeze()
548555

549556
if self.vdim > 1:

0 commit comments

Comments
 (0)