8
8
from __future__ import annotations
9
9
10
10
from abc import ABC , abstractmethod
11
+ from collections .abc import Iterable , Mapping , Sequence
11
12
from typing import TYPE_CHECKING , Any
12
13
from warnings import warn
13
14
16
17
from bayes_opt .target_space import TargetSpace
17
18
18
19
if TYPE_CHECKING :
19
- from collections .abc import Iterable , Mapping , Sequence
20
-
21
20
from numpy .typing import NDArray
22
21
23
22
Float = np .floating [Any ]
@@ -66,12 +65,14 @@ def __init__(
66
65
gamma_osc : float = 0.7 ,
67
66
gamma_pan : float = 1.0 ,
68
67
eta : float = 0.9 ,
69
- minimum_window : NDArray [Float ] | Sequence [float ] | float | Mapping [str , float ] | None = 0.0 ,
68
+ minimum_window : NDArray [Float ] | Sequence [float ] | Mapping [str , float ] | float = 0.0 ,
70
69
) -> None :
71
70
self .gamma_osc = gamma_osc
72
71
self .gamma_pan = gamma_pan
73
72
self .eta = eta
74
- if isinstance (minimum_window , dict ):
73
+
74
+ self .minimum_window_value : NDArray [Float ] | Sequence [float ] | float
75
+ if isinstance (minimum_window , Mapping ):
75
76
self .minimum_window_value = [
76
77
item [1 ] for item in sorted (minimum_window .items (), key = lambda x : x [0 ])
77
78
]
@@ -90,8 +91,9 @@ def initialize(self, target_space: TargetSpace) -> None:
90
91
self .original_bounds = np .copy (target_space .bounds )
91
92
self .bounds = [self .original_bounds ]
92
93
94
+ self .minimum_window : NDArray [Float ] | Sequence [float ]
93
95
# Set the minimum window to an array of length bounds
94
- if isinstance (self .minimum_window_value , (list , np .ndarray )):
96
+ if isinstance (self .minimum_window_value , (Sequence , np .ndarray )):
95
97
if len (self .minimum_window_value ) != len (target_space .bounds ):
96
98
error_msg = "Length of minimum_window must be the same as the number of parameters"
97
99
raise ValueError (error_msg )
0 commit comments