Skip to content

Commit a4467f4

Browse files
committed
debug: Check windows issue of not legal
1 parent d144026 commit a4467f4

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

pyproject.toml

-3
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ select = [
157157
ignore = [
158158
"T201", # TODO: Remove
159159
"D100",
160-
"D101", # Missing docstring in public class
161-
"D102", # Missing docstring in public method (Should be active but it's too much for right now)
162160
"D104", # Missing docstring in public package
163161
"D105", # Missing docstring in magic mthod
164162
"D203", # 1 blank line required before class docstring
@@ -208,7 +206,6 @@ exclude = [
208206
"test/*.py" = [
209207
"S101",
210208
"D102",
211-
"D103",
212209
"D404",
213210
"ARG001",
214211
"A002",

src/ConfigSpace/forbidden.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def __init__(self, hyperparameter: Hyperparameter, values: Iterable[Any]) -> Non
289289
>>> cs.add(forbidden_clause_a)
290290
Forbidden: a in {2, 3}
291291
292-
Note:
292+
Note
293293
----
294294
The forbidden values have to be a subset of the hyperparameter's values.
295295

src/ConfigSpace/hyperparameters/_hp_components.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class UnitScaler(_Transformer[DType]):
129129

130130
lower_vectorized: f64 = field(init=False)
131131
upper_vectorized: f64 = field(init=False)
132-
_scale_vec_to_int: DType = field(init=False)
132+
_size: DType = field(init=False)
133133

134134
def __post_init__(self) -> None:
135135
if self.lower_value >= self.upper_value:
@@ -147,7 +147,7 @@ def __post_init__(self) -> None:
147147
self.lower_vectorized = f64(0)
148148
self.upper_vectorized = f64(1)
149149

150-
self._scale_vec_to_int = self.upper_value - self.lower_value
150+
self._size = self.upper_value - self.lower_value
151151

152152
def to_value(self, vector: Array[f64]) -> Array[DType]:
153153
"""Transform a value from the unit interval to the range."""
@@ -169,9 +169,7 @@ def _unsafe_to_value_single(self, vector: f64) -> f64:
169169
scaled = vector * (_u - _l) + _l
170170
return np.exp(scaled) # type: ignore
171171

172-
_l = self.lower_value
173-
_u = self.upper_value
174-
return vector * (_u - _l) + _l # type: ignore
172+
return vector * self._size + _l # type: ignore
175173

176174
def _unsafe_to_value(self, vector: Array[f64]) -> Array[f64]:
177175
# NOTE: Unsafe as it does not check boundaries, clip or integer'ness
@@ -203,7 +201,7 @@ def vectorize_size(self, size: f64) -> f64:
203201
/ (np.log(self.upper_value) - np.log(self.lower_value)),
204202
)
205203

206-
return f64(size / (self.upper_value - self.lower_value))
204+
return f64(size / self._size)
207205

208206
def legal_value(self, value: Array[Any]) -> Mask:
209207
# If we have a non numeric dtype, we have to unfortunatly go through but by bit
@@ -253,7 +251,10 @@ def legal_vector_single(self, vector: np.number) -> bool:
253251

254252
if not self.log:
255253
inbounds = bool(self.lower_vectorized <= vector <= self.upper_vectorized)
256-
scaled = vector * self._scale_vec_to_int
254+
scaled = vector * self._size
255+
print("SCALED", scaled)
256+
print("is_close", is_close_to_integer_single(scaled, atol=ATOL))
257+
print("inbounds", inbounds)
257258
return bool(is_close_to_integer_single(scaled, atol=ATOL) and inbounds)
258259

259260
value = self._unsafe_to_value_single(vector) # type: ignore

0 commit comments

Comments
 (0)