check_scalar#

skactiveml.utils.check_scalar(x, name, target_type, min_inclusive=True, max_inclusive=True, min_val=None, max_val=None)[source]#

Validate scalar parameters type and value.

Parameters:
xobject

The scalar parameter to validate.

namestr

The name of the parameter to be printed in error messages.

target_typetype or tuple

Acceptable data types for the parameter.

min_inclusivebool, default=True

If True, the minimum valid value is inclusive, otherwise exclusive.

max_inclusivebool, default=True

If True, the maximum valid value is inclusive, otherwise exclusive.

min_valfloat or int, default=None

The minimum valid value the parameter can take. If None (default), it is implied that the parameter does not have a lower bound.

max_valfloat or int, default=None

The maximum valid value the parameter can take. If None (default), it is implied that the parameter does not have an upper bound.

Raises:
TypeError

If the parameter’s type does not match the desired type.

ValueError

If the parameter’s value violates the given bounds.