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

fixes for warnings related to unit tests and nan comparisons #1657

Merged
merged 12 commits into from
Oct 29, 2017
Merged

fixes for warnings related to unit tests and nan comparisons #1657

merged 12 commits into from
Oct 29, 2017

Conversation

jhamman
Copy link
Member

@jhamman jhamman commented Oct 25, 2017

This 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.

@jhamman
Copy link
Member Author

jhamman commented Oct 25, 2017

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 comparison

e.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 numpy.errstat. Thoughts here? I've run out of time for tonight but will pick this up again tomorrow.

@jhamman jhamman requested a review from shoyer October 27, 2017 19:30
@jhamman
Copy link
Member Author

jhamman commented Oct 27, 2017

@shoyer - I'm wondering if we should attack #1652 in stages. The remaining warnings are going to take a bit more effort and this first block included a lot of line changes. I'm a bit concerned that if we let this sit, we will end up with a million merge conflicts.

@shoyer
Copy link
Member

shoyer commented Oct 27, 2017

I'm wondering if we should attack #1652 in stages

Yes, absolutely. Let's do it in stages.

@jhamman
Copy link
Member Author

jhamman commented Oct 27, 2017

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.

Copy link
Member

@shoyer shoyer left a 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!

variable = (f(self.variable, other_variable)
if not reflexive
else f(other_variable, self.variable))
with np.errstate(all='ignore'):
Copy link
Member

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.

@@ -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'):
Copy link
Member

Choose a reason for hiding this comment

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

Also probably unneeded

@shoyer shoyer mentioned this pull request Oct 27, 2017
13 tasks
@shoyer
Copy link
Member

shoyer commented Oct 27, 2017

@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.

@jhamman
Copy link
Member Author

jhamman commented Oct 27, 2017

@shoyer - updated. If all the tests pass, I'll merge tonight.

@shoyer
Copy link
Member

shoyer commented Oct 28, 2017

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?

@jhamman jhamman changed the title fixes for warnings related to unit tests fixes for warnings related to unit tests and nan comparisons Oct 28, 2017
@@ -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')
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

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.

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):
Copy link
Member

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')
Copy link
Member

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.

@jhamman
Copy link
Member Author

jhamman commented Oct 29, 2017

@shoyer - I think this is all good now. We seem to have acquired another unrelated build failures though...

@shoyer shoyer merged commit d016ea7 into pydata:master Oct 29, 2017
@shoyer
Copy link
Member

shoyer commented Oct 29, 2017

Everything passed after the pandas 0.21 fixes in #1669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolve warnings issued in the xarray test suite
2 participants