MCPcopy
hub / github.com/pydata/xarray / test_units_appear_somewhere

Method test_units_appear_somewhere

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

Source from the content-addressed store, hash-verified

2502
2503 @pytest.mark.slow
2504 def test_units_appear_somewhere(self) -> None:
2505 # assign coordinates to all dims so we can test for units
2506 darray = self.darray.assign_coords(
2507 {"x": np.arange(self.darray.x.size), "y": np.arange(self.darray.y.size)}
2508 )
2509
2510 darray.x.attrs["units"] = "x_unit"
2511 darray.y.attrs["units"] = "y_unit"
2512
2513 g = xplt.FacetGrid(darray, col="z")
2514
2515 g.map_dataarray(xplt.contourf, "x", "y")
2516
2517 alltxt = text_in_fig()
2518
2519 # unit should appear as e.g. 'x [x_unit]'
2520 for unit_name in ["x_unit", "y_unit"]:
2521 assert unit_name in "".join(alltxt)
2522
2523
2524@pytest.mark.filterwarnings("ignore:tight_layout cannot")

Callers

nothing calls this directly

Calls 5

map_dataarrayMethod · 0.95
text_in_figFunction · 0.85
arangeMethod · 0.80
assign_coordsMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected