(self)
| 1562 | assert string not in alltxt |
| 1563 | |
| 1564 | def test_colorbar_kwargs(self) -> None: |
| 1565 | # replace label |
| 1566 | self.darray.attrs.pop("long_name") |
| 1567 | self.darray.attrs["units"] = "test_units" |
| 1568 | # check default colorbar label |
| 1569 | self.plotmethod(add_colorbar=True) |
| 1570 | alltxt = text_in_fig() |
| 1571 | assert "testvar [test_units]" in alltxt |
| 1572 | self.darray.attrs.pop("units") |
| 1573 | |
| 1574 | self.darray.name = "testvar" |
| 1575 | self.plotmethod(add_colorbar=True, cbar_kwargs={"label": "MyLabel"}) |
| 1576 | alltxt = text_in_fig() |
| 1577 | assert "MyLabel" in alltxt |
| 1578 | assert "testvar" not in alltxt |
| 1579 | # you can use anything accepted by the dict constructor as well |
| 1580 | self.plotmethod(add_colorbar=True, cbar_kwargs=(("label", "MyLabel"),)) |
| 1581 | alltxt = text_in_fig() |
| 1582 | assert "MyLabel" in alltxt |
| 1583 | assert "testvar" not in alltxt |
| 1584 | # change cbar ax |
| 1585 | _fig, axs = plt.subplots(1, 2, squeeze=False) |
| 1586 | ax = axs[0, 0] |
| 1587 | cax = axs[0, 1] |
| 1588 | self.plotmethod( |
| 1589 | ax=ax, cbar_ax=cax, add_colorbar=True, cbar_kwargs={"label": "MyBar"} |
| 1590 | ) |
| 1591 | assert ax.has_data() |
| 1592 | assert cax.has_data() |
| 1593 | alltxt = text_in_fig() |
| 1594 | assert "MyBar" in alltxt |
| 1595 | assert "testvar" not in alltxt |
| 1596 | # note that there are two ways to achieve this |
| 1597 | _fig, axs = plt.subplots(1, 2, squeeze=False) |
| 1598 | ax = axs[0, 0] |
| 1599 | cax = axs[0, 1] |
| 1600 | self.plotmethod( |
| 1601 | ax=ax, add_colorbar=True, cbar_kwargs={"label": "MyBar", "cax": cax} |
| 1602 | ) |
| 1603 | assert ax.has_data() |
| 1604 | assert cax.has_data() |
| 1605 | alltxt = text_in_fig() |
| 1606 | assert "MyBar" in alltxt |
| 1607 | assert "testvar" not in alltxt |
| 1608 | # see that no colorbar is respected |
| 1609 | self.plotmethod(add_colorbar=False) |
| 1610 | assert "testvar" not in text_in_fig() |
| 1611 | # check that error is raised |
| 1612 | with pytest.raises(ValueError): |
| 1613 | self.plotmethod(add_colorbar=False, cbar_kwargs={"label": "label"}) |
| 1614 | |
| 1615 | def test_verbose_facetgrid(self) -> None: |
| 1616 | a = easy_array((10, 15, 3)) |
nothing calls this directly
no test coverage detected