MCPcopy Index your code
hub / github.com/pydata/xarray / test_properties

Method test_properties

xarray/tests/test_dataarray.py:152–168  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

150 assert expected == repr(mda_long)
151
152 def test_properties(self) -> None:
153 assert_equal(self.dv.variable, self.v)
154 assert_array_equal(self.dv.values, self.v.values)
155 for attr in ["dims", "dtype", "shape", "size", "nbytes", "ndim", "attrs"]:
156 assert getattr(self.dv, attr) == getattr(self.v, attr)
157 assert len(self.dv) == len(self.v)
158 assert_equal(self.dv.variable, self.v)
159 assert set(self.dv.coords) == set(self.ds.coords)
160 for k, v in self.dv.coords.items():
161 assert_array_equal(v, self.ds.coords[k])
162 with pytest.raises(AttributeError):
163 _ = self.dv.dataset
164 assert isinstance(self.ds["x"].to_index(), pd.Index)
165 with pytest.raises(ValueError, match=r"must be 1-dimensional"):
166 self.ds["foo"].to_index()
167 with pytest.raises(AttributeError):
168 self.dv.variable = self.v # type: ignore[misc]
169
170 def test_data_property(self) -> None:
171 array = DataArray(np.zeros((3, 4)))

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
itemsMethod · 0.80
to_indexMethod · 0.45

Tested by

no test coverage detected