Skip to content

Commit

Permalink
add valid type check for choices in categorical parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
danrgll committed Apr 11, 2024
1 parent 3c4b5d2 commit 8fe2366
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions neps/search_spaces/hyperparameters/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def __init__(
)
self.value: None | float | int | str = None

# Check if choices have valid types (float | int | str)
for choice in self.choices:
if not isinstance(choice, (float, int, str)):
raise TypeError(
f'Choice "{choice}" is not of a valid type (float, int, str)')

# Check if 'default' is in 'choices'
if default is not None and default not in self.choices:
raise ValueError(
Expand Down

0 comments on commit 8fe2366

Please sign in to comment.