33import random
44from collections import OrderedDict
55from collections .abc import Iterable
6+ from copy import deepcopy
67
78import numpy as np
89import scipy .spatial
@@ -319,6 +320,7 @@ def __init__(self, func, bounds, loss_per_simplex=None):
319320 else :
320321 self ._bounds_points = sorted (list (map (tuple , itertools .product (* bounds ))))
321322 self ._bbox = tuple (tuple (map (float , b )) for b in bounds )
323+ self ._interior = None
322324
323325 self .ndim = len (self ._bbox )
324326
@@ -337,6 +339,7 @@ def __init__(self, func, bounds, loss_per_simplex=None):
337339 # for the output
338340 self ._min_value = None
339341 self ._max_value = None
342+ self ._old_scale = None
340343 self ._output_multiplier = (
341344 1 # If we do not know anything, do not scale the values
342345 )
@@ -453,7 +456,7 @@ def _simplex_exists(self, simplex):
453456
454457 def inside_bounds (self , point ):
455458 """Check whether a point is inside the bounds."""
456- if hasattr ( self , " _interior" ) :
459+ if self . _interior is not None :
457460 return self ._interior .find_simplex (point , tol = 1e-8 ) >= 0
458461 else :
459462 eps = 1e-8
@@ -988,13 +991,6 @@ def plot_3D(self, with_triangulation=False):
988991
989992 return plotly .offline .iplot (fig )
990993
991- def _get_data (self ):
992- return self .data
993-
994- def _set_data (self , data ):
995- if data :
996- self .tell_many (* zip (* data .items ()))
997-
998994 def _get_iso (self , level = 0.0 , which = "surface" ):
999995 if which == "surface" :
1000996 if self .ndim != 3 or self .vdim != 1 :
@@ -1182,3 +1178,10 @@ def _get_plane_color(simplex):
11821178 opacity = opacity ,
11831179 lighting = lighting ,
11841180 )
1181+
1182+ def _get_data (self ):
1183+ return deepcopy (self .__dict__ )
1184+
1185+ def _set_data (self , state ):
1186+ for k , v in state .items ():
1187+ setattr (self , k , v )
0 commit comments