Skip to content

Commit

Permalink
replace pytest.parametrize
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS committed Jun 14, 2021
1 parent df79713 commit 6e973e2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/python_package_test/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ def generate_trainset_for_monotone_constraints_tests(x3_to_category=True):
return trainset


@pytest.mark.parametrize("test_with_interaction_constraints", [True, False])
@pytest.mark.parametrize("test_with_categorical_variable", [True, False])
def test_monotone_constraints(test_with_interaction_constraints):
def is_increasing(y):
return (np.diff(y) >= 0.0).all()
Expand Down Expand Up @@ -1316,10 +1316,10 @@ def has_interaction(treef):

return not has_interaction_flag.any()

for test_with_categorical_variable in [True, False]:
trainset = generate_trainset_for_monotone_constraints_tests(
test_with_categorical_variable
)
trainset = generate_trainset_for_monotone_constraints_tests(
test_with_categorical_variable
)
for test_with_interaction_constraints in [True, False]:
for monotone_constraints_method in ["basic", "intermediate", "advanced"]:
params = {
"min_data": 20,
Expand Down Expand Up @@ -1399,8 +1399,9 @@ def test_monotone_penalty_max():
}

unconstrained_model = lgb.train(params_unconstrained_model, trainset_unconstrained_model, 10)
unconstrained_model_predictions = unconstrained_model.\
predict(x3_negatively_correlated_with_y.reshape(-1, 1))
unconstrained_model_predictions = unconstrained_model.predict(
x3_negatively_correlated_with_y.reshape(-1, 1)
)

for monotone_constraints_method in ["basic", "intermediate", "advanced"]:
params_constrained_model["monotone_constraints_method"] = monotone_constraints_method
Expand Down

0 comments on commit 6e973e2

Please sign in to comment.