Skip to content

pbounds type mismatch #606

@quuger

Description

@quuger

Describe the bug When using BayesianOptimization with CategoricalParameter, I need to pass pbounds as Sequence[Any], but in __init__ the pbounds parameter is typed as Mapping[str, tuple[float, float]]. This type inconsistency should be fixed — pbounds should use BoundsMapping type like in TargetSpace.

To Reproduce

from bayes_opt import BayesianOptimization, CategoricalParameter

# Example with categorical parameter
pbounds = {
    'x': (2, 4),
    'category': ['option_a', 'option_b', 'option_c']  # CategoricalParameter needs Sequence[Any]
}

optimizer = BayesianOptimization(
    f=lambda x, category: x ** 2,
    pbounds=pbounds
)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions