10000 undo changes in estimator_checks · scikit-learn/scikit-learn@b75f62c · GitHub
[go: up one dir, main page]

Skip to content

Commit b75f62c

Browse files
undo changes in estimator_checks
1 parent 030efea commit b75f62c

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

sklearn/utils/estimator_checks.py

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,37 +4070,30 @@ def check_param_validation(name, estimator_orig):
40704070
f"parameter {param_name} does not have a valid type or value."
40714071
)
40724072

4073-
# If the parameter constraint equals object, the bad parameter
4074-
# doesn't raise an appropriate exception. Object is a placeholder
4075-
# for all kinds of types, that can't be tested properly at the
4076-
# moment, e.g. numpy data types
4077-
# TODO: Remove this, if all data types can be validated correctly
4078-
if estimator_orig._parameter_constraints[param_name] != [object]:
4079-
4080-
estimator = clone(estimator_orig)
4073+
estimator = clone(estimator_orig)
40814074

4082-
# First, check that the error is raised if param doesn't match any valid
4083-
# type.
4084-
estimator.set_params(**{param_name: param_with_bad_type})
4075+
# First, check that the error is raised if param doesn't match any valid
4076+
# type.
4077+
estimator.set_params(**{param_name: param_with_bad_type})
40854078

4086-
for method in methods:
4087-
with raises(ValueError, match=match, err_msg=err_msg):
4088-
getattr(estimator, method)(X, y)
4079+
for method in methods:
4080+
with raises(ValueError, match=match, err_msg=err_msg):
4081+
getattr(estimator, method)(X, y)
40894082

4090-
# Then, for constraints that are more than a type constraint, check that
4091-
# the error is raised if param does match a valid type but does not match
4092-
# any valid value for this type.
4093-
constraints = estimator_orig._parameter_constraints[param_name]
4094-
constraints = [make_constraint(constraint) for constraint in constraints]
4083+
# Then, for constraints that are more than a type constraint, check that
4084+
# the error is raised if param does match a valid type but does not match
4085+
# any valid value for this type.
4086+
constraints = estimator_orig._parameter_constraints[param_name]
4087+
constraints = [make_constraint(constraint) for constraint in constraints]
40954088

4096-
for constraint in constraints:
4097-
try:
4098-
bad_value = generate_invalid_param_val(constraint, constraints)
4099-
except NotImplementedError:
4100-
continue
4089+
for constraint in constraints:
4090+
try:
4091+
bad_value = generate_invalid_param_val(constraint, constraints)
4092+
except NotImplementedError:
4093+
continue
41014094

4102-
estimator.set_params(**{param_name: bad_value})
4095+
estimator.set_params(**{param_name: bad_value})
41034096

4104-
for method in methods:
4105-
with raises(ValueError, match=match, err_msg=err_msg):
4106-
getattr(estimator, method)(X, y)
4097+
for method in methods:
4098+
with raises(ValueError, match=match, err_msg=err_msg):
4099+
getattr(estimator, method)(X, y)

0 commit comments

Comments
 (0)
0