Skip to content

NaT tests need to be fixed on master #2673

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

Closed
dcherian opened this issue Jan 14, 2019 · 3 comments
Closed

NaT tests need to be fixed on master #2673

dcherian opened this issue Jan 14, 2019 · 3 comments

Comments

@dcherian
Copy link
Contributor

=================================== FAILURES ===================================
____________________ TestVariable.test_index_0d_not_a_time _____________________
self = <xarray.tests.test_variable.TestVariable object at 0x7f0dd7b6bda0>
    def test_index_0d_not_a_time(self):
        d = np.datetime64('NaT', 'ns')
        x = self.cls(['x'], [d])
>       self._assertIndexedLikeNDArray(x, d)
xarray/tests/test_variable.py:197: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <xarray.tests.test_variable.TestVariable object at 0x7f0dd7b6bda0>
variable = <xarray.Variable (x: 1)>
array(['NaT'], dtype='datetime64[ns]')
expected_value0 = numpy.datetime64('NaT'), expected_dtype = None
    def _assertIndexedLikeNDArray(self, variable, expected_value0,
                                  expected_dtype=None):
        """Given a 1-dimensional variable, verify that the variable is indexed
        like a numpy.ndarray.
        """
        assert variable[0].shape == ()
        assert variable[0].ndim == 0
        assert variable[0].size == 1
        # test identity
        assert variable.equals(variable.copy())
        assert variable.identical(variable.copy())
        # check value is equal for both ndarray and Variable
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', "In the future, 'NAT == x'")
>           assert variable.values[0] == expected_value0
E           AssertionError: assert numpy.datetime64('NaT') == numpy.datetime64('NaT')
E             -numpy.datetime64('NaT')
E             +numpy.datetime64('NaT')
xarray/tests/test_variable.py:143: AssertionError



________________ TestVariableWithDask.test_index_0d_not_a_time _________________
self = <xarray.tests.test_variable.TestVariableWithDask object at 0x7f0e00bc5978>
    def test_index_0d_not_a_time(self):
        d = np.datetime64('NaT', 'ns')
        x = self.cls(['x'], [d])
>       self._assertIndexedLikeNDArray(x, d)
xarray/tests/test_variable.py:197: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <xarray.tests.test_variable.TestVariableWithDask object at 0x7f0e00bc5978>
variable = <xarray.Variable (x: 1)>
dask.array<shape=(1,), dtype=datetime64[ns], chunksize=(1,)>
expected_value0 = numpy.datetime64('NaT'), expected_dtype = None
    def _assertIndexedLikeNDArray(self, variable, expected_value0,
                                  expected_dtype=None):
        """Given a 1-dimensional variable, verify that the variable is indexed
        like a numpy.ndarray.
        """
        assert variable[0].shape == ()
        assert variable[0].ndim == 0
        assert variable[0].size == 1
        # test identity
        assert variable.equals(variable.copy())
        assert variable.identical(variable.copy())
        # check value is equal for both ndarray and Variable
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', "In the future, 'NAT == x'")
>           assert variable.values[0] == expected_value0
E           AssertionError: assert numpy.datetime64('NaT') == numpy.datetime64('NaT')
E             -numpy.datetime64('NaT')
E             +numpy.datetime64('NaT')
xarray/tests/test_variable.py:143: AssertionError



__________________ TestIndexVariable.test_index_0d_not_a_time __________________
self = <xarray.tests.test_variable.TestIndexVariable object at 0x7f0e01063390>
    def test_index_0d_not_a_time(self):
        d = np.datetime64('NaT', 'ns')
        x = self.cls(['x'], [d])
>       self._assertIndexedLikeNDArray(x, d)
xarray/tests/test_variable.py:197: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <xarray.tests.test_variable.TestIndexVariable object at 0x7f0e01063390>
variable = <xarray.IndexVariable 'x' (x: 1)>
array(['NaT'], dtype='datetime64[ns]')
expected_value0 = numpy.datetime64('NaT'), expected_dtype = None
    def _assertIndexedLikeNDArray(self, variable, expected_value0,
                                  expected_dtype=None):
        """Given a 1-dimensional variable, verify that the variable is indexed
        like a numpy.ndarray.
        """
        assert variable[0].shape == ()
        assert variable[0].ndim == 0
        assert variable[0].size == 1
        # test identity
        assert variable.equals(variable.copy())
        assert variable.identical(variable.copy())
        # check value is equal for both ndarray and Variable
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', "In the future, 'NAT == x'")
>           assert variable.values[0] == expected_value0
E           AssertionError: assert numpy.datetime64('NaT') == numpy.datetime64('NaT')
E             -numpy.datetime64('NaT')
E             +numpy.datetime64('NaT')
xarray/tests/test_variable.py:143: AssertionError
@shoyer
Copy link
Member

shoyer commented Jan 14, 2019

We might just be able to switch these to use np.testing.assert_equal() (though I'm not sure if it handles NaT properly yet).

shoyer added a commit to shoyer/xarray that referenced this issue Jan 15, 2019
Fixes pydata#2673

Note that these were only test failures, not a real bug.
shoyer added a commit that referenced this issue Jan 15, 2019
Fixes #2673

Note that these were only test failures, not a real bug.
@dcherian
Copy link
Contributor Author

Can we remove the warnings filter in the line above your change? Seems like it filtered the warning about this particular issue!

@shoyer
Copy link
Member

shoyer commented Jan 15, 2019 via email

shoyer added a commit that referenced this issue Jan 24, 2019
Fixes #2673

Note that these were only test failures, not a real bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants