8000 BUG: Fix bugs found by testing in release mode. by charris · Pull Request #10193 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix bugs found by testing in release mode. #10193

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

Merged
merged 2 commits into from
Dec 11, 2017

Conversation

charris
Copy link
Member
@charris charris commented Dec 10, 2017

Fix a couple of bugs found by testing in release mode, closes #10185.

  • BUG: Fix numpy.testing.assert_equal in release mode.

    To be complete, the NaT handling needs to raise AssertionError when
    comparing NaT's with different types. That check was previously passed
    on and the resulting check, which would succeed in development mode
    because DeprecationWarning was converted to an error, warns in release
    mode.

  • BUG: Fix test_1d_format test.

    The test failed for numpy installed in release mode as the
    PendingDeprecationWarning issued by object.__format__(a, '30') was no
    longer converted to an error. The fix here is to make the test Python
    version dependent and suppress the warning when needed.

if dtypes_match:
return
else:
raise AssertionError(msg)
Copy link
Member

Choose a reason for hiding this comment

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

This is at best a workaround. It doesn't solve the underlying problem, so the following still has the warning-swallowing problems:

assert_equal(np.void(b'test'), np.datetime64('2017'))

Copy link
Member Author

Choose a reason for hiding this comment

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

It may be incomplete, but I don't think it is a workaround, differing types should be handled with the NaT stuff, not passed on to "==". For the rest, I'm thinking that we should not intercept any of the warning exceptions, just raise all of them. It is only in development mode that they are raised, and those errors should also be fixed in development mode.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see two approaches here for the == fallback,

  • Suppress deprecation warnings, assert_equal should do its thing regardless.
  • Let deprecation warnings raise without conversion to AssertionError

The first can lead to unexpected changes when deprecations expire, the second will generally require fixes or rewrites that could conceivably be difficult before the deprecation expires.

The test failed for numpy installed in release mode as the
PendingDeprecationWarning issued by `object.__format__(a, '30')` was no
longer converted to an error. The fix here is to make the test Python
version dependent and suppress the warning when needed.
To be complete, the NaT handling needs to raise AssertionError when
comparing NaT's with different types. That check was previously passed
on and the resulting check, which would succeed in development mode
because DeprecationWarning was converted to an error, warns in release
mode.
@charris charris force-pushed the fix-deprecation-warning branch from 0074201 to b98e598 Compare December 10, 2017 20:16
@charris
Copy link
Member Author
charris commented Dec 11, 2017

I'm going to put this in just to get 1.14 out. The long term question as to how we should handle deprecation warnings in assert_equal is still open.

@charris charris merged commit 7a8c6b4 into numpy:master Dec 11, 2017
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Dec 11, 2017
@charris charris deleted the fix-deprecation-warning branch December 12, 2017 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missed DeprecationWarning, PendingDeprecationWarning in NumPy tests
2 participants
0