Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] replace pytest.parametrize #4377

Merged
merged 2 commits into from
Jun 15, 2021
Merged

[tests] replace pytest.parametrize #4377

merged 2 commits into from
Jun 15, 2021

Conversation

StrikerRUS
Copy link
Collaborator

Avoid unnecessary trainset generation.

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice change, thanks! Please see one suggestion I left about making it a bit easier to tell which tests failed from the logs.

trainset = generate_trainset_for_monotone_constraints_tests(
test_with_categorical_variable
)
for test_with_interaction_constraints in [True, False]:
Copy link
Collaborator

@jameslamb jameslamb Jun 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this change, but could you update the assert on line 1334 with an error message that will tell us which case it failed on if it fails?

error_msg = f"Model not correctly constrained (test_with_interaction_constraints={test_with_interaction_constraints})"

assert is_correctly_constrained(
    constrained_model, test_with_categorical_variable
), error_msg

Without that, that particular test could fail and we wouldn't know which case it failed on just from the logs.

I think it would also be useful to include the value of monotone_constraints_method in that message too (since it is similarly from an inner for loop), but that's not directly related to this PR so up to you if you want to do that at the same time or separately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Done in 4445482.

predict(x3_negatively_correlated_with_y.reshape(-1, 1))
unconstrained_model_predictions = unconstrained_model.predict(
x3_negatively_correlated_with_y.reshape(-1, 1)
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this formatting a lot more, thank you

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, thanks for speeding up the tests a bit!

@StrikerRUS StrikerRUS merged commit c738c83 into master Jun 15, 2021
@StrikerRUS StrikerRUS deleted the pytest branch June 15, 2021 15:51
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants