Пример #1
0
    def test_diff_attrs_repr_with_array(self):
        attrs_a = {"attr": np.array([0, 1])}

        attrs_b = {"attr": 1}
        expected = dedent("""\
            Differing attributes:
            L   attr: [0 1]
            R   attr: 1
            """).strip()
        actual = formatting.diff_attrs_repr(attrs_a, attrs_b, "equals")
        assert expected == actual

        attrs_b = {"attr": np.array([-3, 5])}
        expected = dedent("""\
            Differing attributes:
            L   attr: [0 1]
            R   attr: [-3  5]
            """).strip()
        actual = formatting.diff_attrs_repr(attrs_a, attrs_b, "equals")
        assert expected == actual

        # should not raise a warning
        attrs_b = {"attr": np.array([0, 1, 2])}
        expected = dedent("""\
            Differing attributes:
            L   attr: [0 1]
            R   attr: [0 1 2]
            """).strip()
        actual = formatting.diff_attrs_repr(attrs_a, attrs_b, "equals")
        assert expected == actual
Пример #2
0
 def assert_variable_attrs_equal(self, ds_a, ds_b):
     # Does not test whether ds_a and ds_b have the same set of variables
     for var_name in ds_a.variables.keys():
         attrs_a = ds_a[var_name].attrs
         attrs_b = ds_b[var_name].attrs
         assert dict_equiv(attrs_a, attrs_b), diff_attrs_repr(
             attrs_a, attrs_b, "identical")
Пример #3
0
 def assert_global_attrs_close(self, attrs_a, attrs_b):
     attrs_a = attrs_a.copy()
     attrs_b = attrs_b.copy()
     self._assert_time_attrs_close(attrs_a, attrs_b)
     self._assert_numerical_attrs_close(attrs_a, attrs_b)
     assert dict_equiv(attrs_a,
                       attrs_b), diff_attrs_repr(attrs_a, attrs_b,
                                                 "identical")