Skip to content

Test failures with pandas 0.24.0 #2717

Closed
@shoyer

Description

@shoyer

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions