-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fixes for warnings related to unit tests and nan comparisons #1657
Conversation
Down to 96 (was 372) warnings in my py36 test environment. Two changes that I could uses some input on: 1 - Numpy element wise comparison def assertEqual(self, a1, a2):
> assert a1 == a2 or (a1 != a1 and a2 != a2)
E DeprecationWarning: elementwise == comparison failed; this will raise an error in the future. @shoyer - you and I put together the assertEqual method a while back. Do we need to check the size of arrays before comparing the values? 2 - Numpy invalid value comparisone.g.: RuntimeWarning: invalid value encountered in greater_equal I'm hoping there is a succinct way of wrapping many of our nan comparing functions in |
Yes, absolutely. Let's do it in stages. |
Okay, so this knocks off the lowest hanging fruit. I'll pull the pytest error out of the travis build and we'll move forward with this. |
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.
Oh my... I forgot that assertRaisesRegexp
was deprecated!
xarray/core/dataarray.py
Outdated
variable = (f(self.variable, other_variable) | ||
if not reflexive | ||
else f(other_variable, self.variable)) | ||
with np.errstate(all='ignore'): |
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.
I don't think we need this here -- this should be caught at the level of the Variable
wrapper.
xarray/core/dataarray.py
Outdated
@@ -1612,7 +1615,8 @@ def func(self, other): | |||
other_coords = getattr(other, 'coords', None) | |||
other_variable = getattr(other, 'variable', other) | |||
with self.coords._merge_inplace(other_coords): | |||
f(self.variable, other_variable) | |||
with np.errstate(all='ignore'): |
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.
Also probably unneeded
@jhamman sorry, looks like you'll need to merge in master, too -- I just put in some conflicting changes with my unicode to netCDF3 PR. |
@shoyer - updated. If all the tests pass, I'll merge tonight. |
This looks good to me. Can you add a note to "what's new" (under bug fixes) about removing the warning when comparing with NaN? |
@@ -1040,7 +1043,7 @@ def test_nc4_scipy(self): | |||
with nc4.Dataset(tmp_file, 'w', format='NETCDF4') as rootgrp: | |||
rootgrp.createGroup('foo') | |||
|
|||
with self.assertRaisesRegexp(TypeError, 'pip install netcdf4'): | |||
with raises_regex(TypeError, 'pip install netcdf4'): | |||
open_dataset(tmp_file, engine='scipy') |
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.
@shoyer - any ideas why this test is failing on Appveyor Py3.6: https://ci.appveyor.com/project/shoyer/xray/build/1.0.2844/job/uarr5gsny3wpx9qm#L3326
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.
Well, we aren't closing this file properly, so I'm not too surprised that Windows is complaining. I don't know why it's only showing up now, though.
For now, just add allow_cleanup_failure=True
to the create_tmp_file()
call. We'll tackle this later in #1668.
xarray/tests/test_backends.py
Outdated
with open_example_dataset('example_1.nc.gz') as expected: | ||
with open_example_dataset('example_1.nc') as actual: | ||
self.assertDatasetIdentical(expected, actual) | ||
if sys.version_info[:2] < (2, 7): |
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.
please revert to my changes here
@@ -1040,7 +1043,7 @@ def test_nc4_scipy(self): | |||
with nc4.Dataset(tmp_file, 'w', format='NETCDF4') as rootgrp: | |||
rootgrp.createGroup('foo') | |||
|
|||
with self.assertRaisesRegexp(TypeError, 'pip install netcdf4'): | |||
with raises_regex(TypeError, 'pip install netcdf4'): | |||
open_dataset(tmp_file, engine='scipy') |
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.
Well, we aren't closing this file properly, so I'm not too surprised that Windows is complaining. I don't know why it's only showing up now, though.
For now, just add allow_cleanup_failure=True
to the create_tmp_file()
call. We'll tackle this later in #1668.
@shoyer - I think this is all good now. We seem to have acquired another unrelated build failures though... |
Everything passed after the pandas 0.21 fixes in #1669 |
git diff upstream/master | flake8 --diff
whats-new.rst
for all changes andapi.rst
for new APIThis first commit just includes the fixes for the warnings issued in our unit tests. I've temporarily added
-W error
to the travis builds so we can see the warnings/errors for all environments. Next step is to address the warnings in the xarray code itself.