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

Method test_imshow_rgb_values_in_valid_range

xarray/tests/test_plot.py:2128–2137  ·  view source on GitHub ↗
(self, dtype)

Source from the content-addressed store, hash-verified

2126
2127 @pytest.mark.parametrize("dtype", [np.uint8, np.int8, np.int16])
2128 def test_imshow_rgb_values_in_valid_range(self, dtype) -> None:
2129 da = DataArray(np.arange(75, dtype=dtype).reshape((5, 5, 3)))
2130 _, ax = plt.subplots()
2131 out = da.plot.imshow(ax=ax).get_array()
2132 assert out is not None
2133 actual_dtype = out.dtype
2134 assert actual_dtype is not None
2135 assert actual_dtype == np.uint8
2136 assert (out[..., :3] == da.values).all() # Compare without added alpha
2137 assert (out[..., -1] == 255).all() # Compare alpha
2138
2139 @pytest.mark.filterwarnings("ignore:Several dimensions of this array")
2140 def test_regression_rgb_imshow_dim_size_one(self) -> None:

Callers

nothing calls this directly

Calls 5

DataArrayClass · 0.90
arangeMethod · 0.80
imshowMethod · 0.80
get_arrayMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected