Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix min window type check #523

Merged

Conversation

phi-friday
Copy link
Contributor

@phi-friday phi-friday commented Sep 20, 2024

minimum_window should be typechecked using Mapping, not dict.
Also, minimum_window_value should be typechecked using Sequence, not list.

And I found it while checking it, is it possible for minimum_window to be None?
The annotation and docstring on minimum_window don't match.
Also, there doesn't seem to be any handling for the case where minimum_window is None in SequentialDomainReductionTransformer._trim().

if current_window_width < self.minimum_window[i]:
width_deficit = (self.minimum_window[i] - current_window_width) / 2.0

In my opinion, typing.Optional was used to mean minimum_window has a default value.
minimum_window: Optional[Union[List[float], float, Dict[str, float]]] = 0.0

So it would be nice to add a process to __init__ to either not accept None, or to convert to the default value when it is None.

@till-m
Copy link
Member

till-m commented Sep 30, 2024

Give me some time to look into this :)

@till-m
Copy link
Member

till-m commented Oct 1, 2024

You're right, this should not accept None!

@phi-friday
Copy link
Contributor Author

You're right, this should not accept None!

Should I modify it so that it doesn't accept None? Or should I change it to default?

@till-m
Copy link
Member

till-m commented Oct 1, 2024

it would be great if you remove the None option as part of this PR 👍

@phi-friday
Copy link
Contributor Author

it would be great if you remove the None option as part of this PR 👍

I fixed it.

@till-m till-m merged commit c48e566 into bayesian-optimization:master Oct 1, 2024
11 checks passed
@phi-friday phi-friday deleted the fix-min-window-type-check branch October 1, 2024 09:32
till-m added a commit to till-m/BayesianOptimization that referenced this pull request Oct 9, 2024
* fix: import error from exception module (bayesian-optimization#525)

* fix: replace list with sequence (bayesian-optimization#524)

* Fix min window type check (bayesian-optimization#523)

* fix: replace dict with Mapping

* fix: replace list with Sequence

* fix: add type hint

* fix: does not accept None

* Change docs badge (bayesian-optimization#527)

* fix: parameter, target_space

* fix: constraint, bayesian_optimization

* fix: ParamsType

---------

Co-authored-by: till-m <36440677+till-m@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants