File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -862,6 +862,29 @@ def __setstate__(self, state):
862
862
self .losses_combined .update (losses_combined )
863
863
864
864
865
+ def all_intervals_between (
866
+ learner : Learner1D ,
867
+ x_min : float | None = None ,
868
+ x_max : float | None = None ,
869
+ real : bool = True ,
870
+ ) -> list [list [float ]]:
871
+ """Returns all intervals between the given bounds."""
872
+ neighbors = learner .neighbors if real else learner .neighbors_combined
873
+ if x_min is None :
874
+ x_left = learner .bounds [0 ]
875
+ elif x_min in neighbors :
876
+ x_left = x_min
877
+ else :
878
+ _ , x_left = learner ._find_neighbors (x_min , neighbors )
879
+ if x_max is None :
880
+ x_right = learner .bounds [1 ]
881
+ elif x_max in neighbors :
882
+ x_right = x_max
883
+ else :
884
+ x_right , _ = learner ._find_neighbors (x_max , neighbors )
885
+ return [ival for x , ival in neighbors .items () if x > x_left and x < x_right ]
886
+
887
+
865
888
def loss_manager (x_scale : float ) -> dict [Interval , float ]:
866
889
def sort_key (ival , loss ):
867
890
loss , ival = finite_loss (ival , loss , x_scale )
You can’t perform that action at this time.
0 commit comments