Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
### Enhancements

- Add python 3.13 to list of supported versions ([#158](https://github.com/mpytools/mplotutils/pull/158)).
- Increased test coverage ([#180](https://github.com/mpytools/mplotutils/pull/180)).

### Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion mplotutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

try:
__version__ = _get_version("mplotutils")
except Exception:
except Exception: # pragma: no cover
# Local copy or not installed with setuptools.
# Disable minimum version checks on downstream libraries.
__version__ = "999"
Expand Down
2 changes: 1 addition & 1 deletion mplotutils/_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def colorbar(
raise ValueError(msg)

if not all(isinstance(ax, mpl.axes.Axes) for ax in axs):
raise TypeError("ax must be of Type mpl.axes.Axes")
raise TypeError("ax must be of type mpl.axes.Axes")

f = axs[0].get_figure()

Expand Down
10 changes: 10 additions & 0 deletions mplotutils/tests/test_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ def test_colorbar_deprecate_ax1():
mpu.colorbar(h, ax1=ax)


def test_colorbar_error_not_axes():

with pytest.raises(TypeError, match="ax must be of type mpl.axes.Axes"):
mpu.colorbar(None, object())

with figure_context() as f:
with pytest.raises(TypeError, match="ax must be of type mpl.axes.Axes"):
mpu.colorbar(None, f)


def test_colorbar_different_figures():
with figure_context() as f1, figure_context() as f2:
ax1 = f1.subplots()
Expand Down
2 changes: 1 addition & 1 deletion mplotutils/tests/test_hatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_hatch_pattern(self):

h = self.function(da, "*", ax=ax)
assert h.hatches == ["", "*"]
h = self.function(da, "//", ax=ax)
h = self.function(da, "//")
assert h.hatches == ["", "//"]

def test_hatch_label(self):
Expand Down
3 changes: 3 additions & 0 deletions mplotutils/tests/test_label_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ def test_works():
with subplots_context() as (f, ax):
ylabel_map("ylabel", ax=ax)
xlabel_map("ylabel", ax=ax)

ylabel_map("ylabel")
xlabel_map("ylabel")
14 changes: 9 additions & 5 deletions mplotutils/tests/test_mapticklabels.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import cartopy.crs as ccrs
import numpy as np
import pytest

import mplotutils as mpu

from . import subplots_context


def test_yticklabels_robinson():
@pytest.mark.parametrize("pass_ax", (True, False))
def test_yticklabels_robinson(pass_ax):
with subplots_context(subplot_kw=dict(projection=ccrs.Robinson())) as (f, ax):
ax.set_global()

lat = np.arange(-90, 91, 20)

mpu.yticklabels(lat, ax=ax, size=8)
ax_ = ax if pass_ax else None
mpu.yticklabels(lat, ax=ax_, size=8)

x_pos = -179.99

Expand Down Expand Up @@ -47,13 +50,14 @@ def test_yticklabels_robinson_180():
assert ax.texts[-1].get_text() == "70°N"


def test_xticklabels_robinson():
@pytest.mark.parametrize("pass_ax", (True, False))
def test_xticklabels_robinson(pass_ax):
with subplots_context(subplot_kw=dict(projection=ccrs.Robinson())) as (f, ax):
ax.set_global()

lon = np.arange(-180, 181, 60)

mpu.xticklabels(lon, ax=ax, size=8)
ax_ = ax if pass_ax else None
mpu.xticklabels(lon, ax=ax_, size=8)

y_pos = -89.99

Expand Down