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

Function test_plot_transposes_properly

xarray/tests/test_plot.py:3252–3260  ·  view source on GitHub ↗
(plotfunc)

Source from the content-addressed store, hash-verified

3250@requires_matplotlib
3251@pytest.mark.parametrize("plotfunc", ["pcolormesh", "imshow"])
3252def test_plot_transposes_properly(plotfunc) -> None:
3253 # test that we aren't mistakenly transposing when the 2 dimensions have equal sizes.
3254 da = xr.DataArray([np.sin(2 * np.pi / 10 * np.arange(10))] * 10, dims=("y", "x"))
3255 with figure_context():
3256 hdl = getattr(da.plot, plotfunc)(x="x", y="y")
3257 # get_array doesn't work for contour, contourf. It returns the colormap intervals.
3258 # pcolormesh returns 1D array but imshow returns a 2D array so it is necessary
3259 # to ravel() on the LHS
3260 assert_array_equal(hdl.get_array().ravel(), da.to_masked_array().ravel())
3261
3262
3263@requires_matplotlib

Callers

nothing calls this directly

Calls 5

to_masked_arrayMethod · 0.95
figure_contextFunction · 0.85
sinMethod · 0.80
arangeMethod · 0.80
get_arrayMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…