Skip to content

Commit 2299184

Browse files
committed
2D: add DeprecationWarning
1 parent d564e0c commit 2299184

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

adaptive/learner/learner2D.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from collections import OrderedDict
55
from copy import copy
66
from math import sqrt
7+
import warnings
78

89
import numpy as np
910
from scipy import interpolate
@@ -230,7 +231,6 @@ class Learner2D(BaseLearner):
230231
triangle area, to determine the loss. See the notes
231232
for more details.
232233
233-
234234
Attributes
235235
----------
236236
data : dict
@@ -384,7 +384,7 @@ def _data_interp(self):
384384
if self.pending_points:
385385
points = list(self.pending_points)
386386
if self.bounds_are_done:
387-
ip = self.interpolate()
387+
ip = self.interpolate(scaled=True)
388388
values = ip(self._scale(points))
389389
else:
390390
# Without the bounds the interpolation cannot be done properly,
@@ -403,17 +403,24 @@ def _data_combined(self):
403403
return points_combined, values_combined
404404

405405
def ip(self):
406-
"""Deprecated, use `self.interpolate()`"""
406+
"""Deprecated, use `self.interpolate(scaled=True)`"""
407+
warnings.warn(
408+
"`learner.ip()` is deprecated, use `learner.interpolate(scaled=True)`."
409+
" This will be removed in v1.0.",
410+
DeprecationWarning,
411+
)
407412
return self.interpolate(scaled=True)
408413

409-
def interpolate(self, *, scaled=True):
414+
def interpolate(self, *, scaled=False):
410415
"""A `scipy.interpolate.LinearNDInterpolator` instance
411416
containing the learner's data.
412417
413418
Parameters
414419
----------
415420
scaled : bool
416-
True if all points are inside the unit-square [(-0.5, 0.5), (-0.5, 0.5)].
421+
Use True if all points are inside the
422+
unit-square [(-0.5, 0.5), (-0.5, 0.5)] or False if
423+
the data points are inside the ``learner.bounds``.
417424
418425
Returns
419426
-------
@@ -534,7 +541,7 @@ def ask(self, n, tell_pending=True):
534541
def loss(self, real=True):
535542
if not self.bounds_are_done:
536543
return np.inf
537-
ip = self.interpolate() if real else self._interpolate_combined()
544+
ip = self.interpolate(scaled=True) if real else self._interpolate_combined()
538545
losses = self.loss_per_triangle(ip)
539546
return losses.max()
540547

@@ -579,8 +586,8 @@ def plot(self, n=None, tri_alpha=0):
579586
lbrt = x[0], y[0], x[1], y[1]
580587

581588
if len(self.data) >= 4:
582-
ip = self.interpolate()
583-
x, y, z = self.data_on_grid(n)
589+
ip = self.interpolate(scaled=True)
590+
x, y, z = self.interpolated_on_grid(n)
584591

585592
if self.vdim > 1:
586593
ims = {

0 commit comments

Comments
 (0)