-
Notifications
You must be signed in to change notification settings - Fork 231
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
Fix 7 sources of warnings in the tests #339
Fix 7 sources of warnings in the tests #339
Conversation
Besides my own TOC to remove warnings, this is related to #189 |
@@ -704,7 +704,7 @@ def _initialize_metric_mahalanobis(input, init='identity', random_state=None, | |||
elif init == 'covariance': | |||
if input.ndim == 3: | |||
# if the input are tuples, we need to form an X by deduplication | |||
X = np.vstack({tuple(row) for row in input.reshape(-1, n_features)}) | |||
X = np.unique(np.vstack(input), axis=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be faster in some cases, and more RAM-hungry in others. Overall I think it's probably fine, and if users are particularly sensitive to the RAM requirement they can perform their own dedup and pass a 2-d input directly.
Merged, thanks! |
@mvargas33 as we discussed informally, for the last category of warnings related to SCML, I would rather provide the |
Wiil do, in a separate PR. I agree this try/catch is an overkill and makes the code more illegible. |
Solution: Replace np.int for np.int64 for more precision
Solution: Do a refactor to get the same result. The above is equivalent to:
X = np.unique(np.vstack(input), axis=0)
Made a little script to verify the behaviour. Also, all tests pass.
Solution: Register these marks in a pytest.ini file, as the docs suggest
Solution: Refactor the test to use pytest.warns isntead of old API
Solution:" Change to future default, changing rcond=None now
6. Sixth warning
All user warnings that were not being catched in
test_generate_knntriplets
attest_constraints.py
, and this is exactly was this test is meant to test.Solution: Catch the
UserWarnings
with pytest.warns(UserWarning)By default any usage of SCML with the default constructor, will throw the following warning:
If this warning will be always be thrown for
SCML
andSCML_Sueprvized
, it should be catched withpytest.warns(UserWarning)
and check that the message is exactly that "the value of n_basis was not selected".Changed in
test_triplets_classifiers.py
as an example, if needed I can extend this pattern to many warnings of this kind thrown intest_mahalanobis_mixin.py
and in other files.Overall result: Reduced from 1.117 to 482 warnings across all tests. Many left are being thrown because of the last warning described