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

Method test_colors

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

Source from the content-addressed store, hash-verified

1848 return c[0], c[1], c[2]
1849
1850 def test_colors(self) -> None:
1851 # with single color, we don't want rgb array
1852 artist = self.plotmethod(colors="k")
1853 assert artist.cmap.colors[0] == "k"
1854
1855 # 2 colors, will repeat every other tick:
1856 artist = self.plotmethod(colors=["k", "b"])
1857 assert artist.cmap.colors[:2] == ["k", "b"]
1858
1859 # 4 colors, will repeat every 4th tick:
1860 artist = self.darray.plot.contour(
1861 levels=[-0.5, 0.0, 0.5, 1.0], colors=["k", "r", "w", "b"]
1862 )
1863 assert artist.cmap.colors[:5] == ["k", "r", "w", "b"] # type: ignore[attr-defined,unused-ignore]
1864
1865 # the last color is now under "over"
1866 assert self._color_as_tuple(artist.cmap.get_over()) == (0.0, 0.0, 1.0)
1867
1868 def test_colors_np_levels(self) -> None:
1869 # https://github.com/pydata/xarray/issues/3284

Callers

nothing calls this directly

Calls 2

_color_as_tupleMethod · 0.95
contourMethod · 0.80

Tested by

no test coverage detected