4
4
from collections import OrderedDict
5
5
from copy import copy
6
6
from math import sqrt
7
+ import warnings
7
8
8
9
import numpy as np
9
10
from scipy import interpolate
@@ -230,7 +231,6 @@ class Learner2D(BaseLearner):
230
231
triangle area, to determine the loss. See the notes
231
232
for more details.
232
233
233
-
234
234
Attributes
235
235
----------
236
236
data : dict
@@ -384,7 +384,7 @@ def _data_interp(self):
384
384
if self .pending_points :
385
385
points = list (self .pending_points )
386
386
if self .bounds_are_done :
387
- ip = self .interpolate ()
387
+ ip = self .interpolate (scaled = True )
388
388
values = ip (self ._scale (points ))
389
389
else :
390
390
# Without the bounds the interpolation cannot be done properly,
@@ -403,17 +403,24 @@ def _data_combined(self):
403
403
return points_combined , values_combined
404
404
405
405
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
+ )
407
412
return self .interpolate (scaled = True )
408
413
409
- def interpolate (self , * , scaled = True ):
414
+ def interpolate (self , * , scaled = False ):
410
415
"""A `scipy.interpolate.LinearNDInterpolator` instance
411
416
containing the learner's data.
412
417
413
418
Parameters
414
419
----------
415
420
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``.
417
424
418
425
Returns
419
426
-------
@@ -534,7 +541,7 @@ def ask(self, n, tell_pending=True):
534
541
def loss (self , real = True ):
535
542
if not self .bounds_are_done :
536
543
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 ()
538
545
losses = self .loss_per_triangle (ip )
539
546
return losses .max ()
540
547
@@ -579,8 +586,8 @@ def plot(self, n=None, tri_alpha=0):
579
586
lbrt = x [0 ], y [0 ], x [1 ], y [1 ]
580
587
581
588
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 )
584
591
585
592
if self .vdim > 1 :
586
593
ims = {
0 commit comments