| 192 | |
| 193 | @pytest.mark.parametrize("binary_string", [False, True]) |
| 194 | def test_imshow_xarray(binary_string): |
| 195 | img = np.random.random((20, 30)) |
| 196 | da = xr.DataArray(img, dims=["dim_rows", "dim_cols"]) |
| 197 | fig = px.imshow(da, binary_string=binary_string) |
| 198 | # Dimensions are used for axis labels and coordinates |
| 199 | assert fig.layout.xaxis.title.text == "dim_cols" |
| 200 | assert fig.layout.yaxis.title.text == "dim_rows" |
| 201 | if not binary_string: |
| 202 | assert np.all(np.array(fig.data[0].x) == np.array(da.coords["dim_cols"])) |
| 203 | |
| 204 | |
| 205 | def test_imshow_xarray_slicethrough(): |