@@ -86,7 +86,8 @@ def validate(self):
8686 """
8787 if not isinstance (self ._original_space , dict ):
8888 raise TypeError (
89- f"Search space must be a dict, got { type (self ._original_space ).__name__ } "
89+ "Search space must be a dict, "
90+ f"got { type (self ._original_space ).__name__ } "
9091 )
9192
9293 if not self ._original_space :
@@ -99,13 +100,14 @@ def _validate_dimension(self, name: str, values):
99100 """Validate a single dimension."""
100101 if isinstance (values , tuple ):
101102 self ._validate_continuous (name , values )
102- elif isinstance (values , ( list , np .ndarray ) ):
103+ elif isinstance (values , list | np .ndarray ):
103104 self ._validate_discrete (name , values )
104105 else :
105106 raise TypeError (
106107 f"Parameter '{ name } ': expected list (discrete) or tuple (continuous), "
107108 f"got { type (values ).__name__ } . "
108- f"Use [a, b, c] for discrete values or (low, high) for continuous ranges."
109+ "Use [a, b, c] for discrete values "
110+ "or (low, high) for continuous ranges."
109111 )
110112
111113 def _validate_continuous (self , name : str , values : tuple ):
@@ -130,7 +132,7 @@ def _validate_continuous(self, name: str, values: tuple):
130132 low , high = values [0 ], values [1 ]
131133
132134 # Check low and high are numeric
133- if not isinstance (low , ( int , float )) or not isinstance (high , ( int , float ) ):
135+ if not isinstance (low , int | float ) or not isinstance (high , int | float ):
134136 raise TypeError (
135137 f"Parameter '{ name } ': low and high must be numeric, "
136138 f"got low={ type (low ).__name__ } , high={ type (high ).__name__ } "
@@ -190,7 +192,7 @@ def _parse_continuous_options(self, name: str, values: tuple):
190192 f"Use 'log' for logarithmic scale."
191193 )
192194 log_scale = True
193- elif isinstance (third , ( int , float ) ):
195+ elif isinstance (third , int | float ):
194196 n_points = int (third )
195197 else :
196198 raise TypeError (
@@ -200,7 +202,7 @@ def _parse_continuous_options(self, name: str, values: tuple):
200202 elif len (values ) == 4 :
201203 # (low, high, n_points, "log")
202204 third , fourth = values [2 ], values [3 ]
203- if not isinstance (third , ( int , float ) ):
205+ if not isinstance (third , int | float ):
204206 raise TypeError (
205207 f"Parameter '{ name } ': n_points must be numeric, "
206208 f"got { type (third ).__name__ } "
0 commit comments