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

Test failures with pandas 0.24.0 #2717

Closed
shoyer opened this issue Jan 26, 2019 · 0 comments
Closed

Test failures with pandas 0.24.0 #2717

shoyer opened this issue Jan 26, 2019 · 0 comments

Comments

@shoyer
Copy link
Member

shoyer commented Jan 26, 2019

From a recent build on Travis-CI:

=================================== FAILURES ===================================
___________________ test_cf_timedelta[timedeltas7-days-nan] ____________________
timedeltas = numpy.datetime64('NaT'), units = 'days', numbers = array(nan)
    @pytest.mark.parametrize(
        ['timedeltas', 'units', 'numbers'],
        [('1D', 'days', np.int64(1)),
         (['1D', '2D', '3D'], 'days', np.array([1, 2, 3], 'int64')),
         ('1h', 'hours', np.int64(1)),
         ('1ms', 'milliseconds', np.int64(1)),
         ('1us', 'microseconds', np.int64(1)),
         (['NaT', '0s', '1s'], None, [np.nan, 0, 1]),
         (['30m', '60m'], 'hours', [0.5, 1.0]),
         (np.timedelta64('NaT', 'ns'), 'days', np.nan),
         (['NaT', 'NaT'], 'days', [np.nan, np.nan])])
    def test_cf_timedelta(timedeltas, units, numbers):
        timedeltas = pd.to_timedelta(timedeltas, box=False)
        numbers = np.array(numbers)
    
        expected = numbers
>       actual, _ = coding.times.encode_cf_timedelta(timedeltas, units)
xarray/tests/test_coding_times.py:550: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
timedeltas = numpy.datetime64('NaT'), units = 'days'
    def encode_cf_timedelta(timedeltas, units=None):
        if units is None:
            units = infer_timedelta_units(timedeltas)
    
        np_unit = _netcdf_to_numpy_timeunit(units)
>       num = 1.0 * timedeltas / np.timedelta64(1, np_unit)
E       TypeError: ufunc multiply cannot use operands with types dtype('float64') and dtype('<M8[ns]')
xarray/coding/times.py:379: TypeError
_____________________ TestDataArray.test_struct_array_dims _____________________
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7fb508944a90>
    def test_struct_array_dims(self):
        """
        This test checks subraction of two DataArrays for the case
        when dimension is a structured array.
        """
        # GH837, GH861
        # checking array subraction when dims are the same
        p_data = np.array([('John', 180), ('Stacy', 150), ('Dick', 200)],
                          dtype=[('name', '|S256'), ('height', object)])
    
        p_data_1 = np.array([('John', 180), ('Stacy', 150), ('Dick', 200)],
                            dtype=[('name', '|S256'), ('height', object)])
    
        p_data_2 = np.array([('John', 180), ('Dick', 200)],
                            dtype=[('name', '|S256'), ('height', object)])
    
        weights_0 = DataArray([80, 56, 120], dims=['participant'],
                              coords={'participant': p_data})
    
        weights_1 = DataArray([81, 52, 115], dims=['participant'],
                              coords={'participant': p_data_1})
    
        actual = weights_1 - weights_0
    
        expected = DataArray([1, -4, -5], dims=['participant'],
                             coords={'participant': p_data})
    
        assert_identical(actual, expected)
    
        # checking array subraction when dims are not the same
        p_data_1 = np.array([('John', 180), ('Stacy', 151), ('Dick', 200)],
                            dtype=[('name', '|S256'), ('height', object)])
    
        weights_1 = DataArray([81, 52, 115], dims=['participant'],
                              coords={'participant': p_data_1})
    
        actual = weights_1 - weights_0
    
        expected = DataArray([1, -5], dims=['participant'],
                             coords={'participant': p_data_2})
    
>       assert_identical(actual, expected)
E       AssertionError: Left and right DataArray objects are not identical
E       
E       Differing values:
E       L
E           array([-5,  1])
E       R
E           array([ 1, -5])
E       Differing coordinates:
E       L * participant  (participant) object (b'Dick', 200) (b'John', 180)
E       R * participant  (participant) [('name', 'S256'), ('height', 'O')] (b'John', 180) (b'Dick', 200)
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

No branches or pull requests

1 participant