Skip to content

Two strange errors in tests TestVariable using .copy() #3778

@ArchangeGabriel

Description

@ArchangeGabriel

Setup is as described in #3777.

The two failures are the following ones:

____________________ TestVariable.test_index_0d_not_a_time _____________________

self = <xarray.tests.test_units.TestVariable object at 0x7f3926b2ad00>

    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:206: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <xarray.tests.test_units.TestVariable object at 0x7f3926b2ad00>
variable = <xarray.Variable (x: 1)>
<Quantity(['NaT'], 'meter')>
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())
E       AssertionError: assert False
E        +  where False = <bound method Variable.equals of <xarray.Variable (x: 1)>\n<Quantity(['NaT'], 'meter')>>(<xarray.Variable (x: 1)>\n<Quantity(['NaT'], 'meter')>)
E        +    where <bound method Variable.equals of <xarray.Variable (x: 1)>\n<Quantity(['NaT'], 'meter')>> = <xarray.Variable (x: 1)>\n<Quantity(['NaT'], 'meter')>.equals
E        +    and   <xarray.Variable (x: 1)>\n<Quantity(['NaT'], 'meter')> = <bound method Variable.copy of <xarray.Variable (x: 1)>\n<Quantity(['NaT'], 'meter')>>()
E        +      where <bound method Variable.copy of <xarray.Variable (x: 1)>\n<Quantity(['NaT'], 'meter')>> = <xarray.Variable (x: 1)>\n<Quantity(['NaT'], 'meter')>.copy

xarray/tests/test_variable.py:151: AssertionError
_____________________ TestVariable.test_equals_all_dtypes ______________________

self = <xarray.tests.test_units.TestVariable object at 0x7f39282b4e50>

    def test_equals_all_dtypes(self):
        for v, _ in self.example_1d_objects():
            v2 = v.copy()
>           assert v.equals(v2)
E           AssertionError: assert False
E            +  where False = <bound method Variable.equals of <xarray.Variable (x: 3)>\n<Quantity(['2000-01-01T00:00:00.000000000' '2000-01-02T00:00:00.000000000'\n '2000-01-03T00:00:00.000000000'], 'meter')>>(<xarray.Variable (x: 3)>\n<Quantity(['2000-01-01T00:00:00.000000000' '2000-01-02T00:00:00.000000000'\n '2000-01-03T00:00:00.000000000'], 'meter')>)
E            +    where <bound method Variable.equals of <xarray.Variable (x: 3)>\n<Quantity(['2000-01-01T00:00:00.000000000' '2000-01-02T00:00:00.000000000'\n '2000-01-03T00:00:00.000000000'], 'meter')>> = <xarray.Variable (x: 3)>\n<Quantity(['2000-01-01T00:00:00.000000000' '2000-01-02T00:00:00.000000000'\n '2000-01-03T00:00:00.000000000'], 'meter')>.equals

xarray/tests/test_variable.py:386: AssertionError

I have no idea what’s wrong here.

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