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

Method setUp

xarray/tests/test_plot.py:1293–1316  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1291
1292 @pytest.fixture(autouse=True)
1293 def setUp(self) -> None:
1294 da = DataArray(
1295 easy_array((10, 15), start=-1),
1296 dims=["y", "x"],
1297 coords={"y": np.arange(10), "x": np.arange(15)},
1298 )
1299 # add 2d coords
1300 ds = da.to_dataset(name="testvar")
1301 x, y = np.meshgrid(da.x.values, da.y.values)
1302 ds["x2d"] = DataArray(x, dims=["y", "x"])
1303 ds["y2d"] = DataArray(y, dims=["y", "x"])
1304 ds = ds.set_coords(["x2d", "y2d"])
1305 # set darray and plot method
1306 self.darray: DataArray = ds.testvar
1307
1308 # Add CF-compliant metadata
1309 self.darray.attrs["long_name"] = "a_long_name"
1310 self.darray.attrs["units"] = "a_units"
1311 self.darray.x.attrs["long_name"] = "x_long_name"
1312 self.darray.x.attrs["units"] = "x_units"
1313 self.darray.y.attrs["long_name"] = "y_long_name"
1314 self.darray.y.attrs["units"] = "y_units"
1315
1316 self.plotmethod = getattr(self.darray.plot, self.plotfunc.__name__)
1317
1318 def test_label_names(self) -> None:
1319 self.plotmethod()

Callers

nothing calls this directly

Calls 5

to_datasetMethod · 0.95
DataArrayClass · 0.90
easy_arrayFunction · 0.85
arangeMethod · 0.80
set_coordsMethod · 0.80

Tested by

no test coverage detected