diff --git a/pyproject.toml b/pyproject.toml index 751c9d41..0bce8620 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ test = [ "coverage[toml]>=7.0.0", "typeguard>=4.4.0", "pandas", + "astropy" ] dev = [ "tox", diff --git a/requirements-310.txt b/requirements-310.txt index dd0468aa..eb9593cf 100644 --- a/requirements-310.txt +++ b/requirements-310.txt @@ -1,5 +1,9 @@ # This file was autogenerated by uv via the following command: # uv pip compile pyproject.toml --extra test --resolution highest --python 3.10 -o requirements-310.txt +astropy==6.1.7 + # via matplot2tikz (pyproject.toml) +astropy-iers-data==0.2026.2.2.0.48.1 + # via astropy colorama==0.4.6 # via pytest contourpy==1.3.2 @@ -23,11 +27,14 @@ matplotlib==3.10.7 numpy==2.2.6 # via # matplot2tikz (pyproject.toml) + # astropy # contourpy # matplotlib # pandas + # pyerfa packaging==25.0 # via + # astropy # matplotlib # pytest pandas==2.3.3 @@ -40,6 +47,8 @@ pluggy==1.6.0 # via # pytest # pytest-cov +pyerfa==2.0.1.5 + # via astropy pygments==2.19.2 # via pytest pyparsing==3.2.5 @@ -56,6 +65,8 @@ python-dateutil==2.9.0.post0 # pandas pytz==2025.2 # via pandas +pyyaml==6.0.3 + # via astropy six==1.17.0 # via python-dateutil tomli==2.3.0 diff --git a/requirements-311.txt b/requirements-311.txt index eb35d360..96bfeab8 100644 --- a/requirements-311.txt +++ b/requirements-311.txt @@ -1,5 +1,9 @@ # This file was autogenerated by uv via the following command: # uv pip compile pyproject.toml --extra test --resolution highest --python 3.11 -o requirements-311.txt +astropy==7.2.0 + # via matplot2tikz (pyproject.toml) +astropy-iers-data==0.2026.2.2.0.48.1 + # via astropy colorama==0.4.6 # via pytest contourpy==1.3.3 @@ -21,11 +25,14 @@ matplotlib==3.10.7 numpy==2.3.4 # via # matplot2tikz (pyproject.toml) + # astropy # contourpy # matplotlib # pandas + # pyerfa packaging==25.0 # via + # astropy # matplotlib # pytest pandas==2.3.3 @@ -38,6 +45,8 @@ pluggy==1.6.0 # via # pytest # pytest-cov +pyerfa==2.0.1.5 + # via astropy pygments==2.19.2 # via pytest pyparsing==3.2.5 @@ -54,6 +63,8 @@ python-dateutil==2.9.0.post0 # pandas pytz==2025.2 # via pandas +pyyaml==6.0.3 + # via astropy six==1.17.0 # via python-dateutil tomli==2.3.0 diff --git a/requirements-312.txt b/requirements-312.txt index b9e56f36..4aa7e6fa 100644 --- a/requirements-312.txt +++ b/requirements-312.txt @@ -1,5 +1,9 @@ # This file was autogenerated by uv via the following command: # uv pip compile pyproject.toml --extra test --resolution highest --python 3.12 -o requirements-312.txt +astropy==7.2.0 + # via matplot2tikz (pyproject.toml) +astropy-iers-data==0.2026.2.2.0.48.1 + # via astropy colorama==0.4.6 # via pytest contourpy==1.3.3 @@ -21,11 +25,14 @@ matplotlib==3.10.7 numpy==2.3.4 # via # matplot2tikz (pyproject.toml) + # astropy # contourpy # matplotlib # pandas + # pyerfa packaging==25.0 # via + # astropy # matplotlib # pytest pandas==2.3.3 @@ -38,6 +45,8 @@ pluggy==1.6.0 # via # pytest # pytest-cov +pyerfa==2.0.1.5 + # via astropy pygments==2.19.2 # via pytest pyparsing==3.2.5 @@ -54,6 +63,8 @@ python-dateutil==2.9.0.post0 # pandas pytz==2025.2 # via pandas +pyyaml==6.0.3 + # via astropy six==1.17.0 # via python-dateutil typeguard==4.4.4 diff --git a/requirements-313.txt b/requirements-313.txt index 6f103024..f3243b5a 100644 --- a/requirements-313.txt +++ b/requirements-313.txt @@ -1,5 +1,9 @@ # This file was autogenerated by uv via the following command: # uv pip compile pyproject.toml --extra test --resolution highest --python 3.13 -o requirements-313.txt +astropy==7.2.0 + # via matplot2tikz (pyproject.toml) +astropy-iers-data==0.2026.2.2.0.48.1 + # via astropy colorama==0.4.6 # via pytest contourpy==1.3.3 @@ -21,11 +25,14 @@ matplotlib==3.10.7 numpy==2.3.4 # via # matplot2tikz (pyproject.toml) + # astropy # contourpy # matplotlib # pandas + # pyerfa packaging==25.0 # via + # astropy # matplotlib # pytest pandas==2.3.3 @@ -38,6 +45,8 @@ pluggy==1.6.0 # via # pytest # pytest-cov +pyerfa==2.0.1.5 + # via astropy pygments==2.19.2 # via pytest pyparsing==3.2.5 @@ -54,6 +63,8 @@ python-dateutil==2.9.0.post0 # pandas pytz==2025.2 # via pandas +pyyaml==6.0.3 + # via astropy six==1.17.0 # via python-dateutil typeguard==4.4.4 diff --git a/requirements-314.txt b/requirements-314.txt index 8bc4d7df..56d3b797 100644 --- a/requirements-314.txt +++ b/requirements-314.txt @@ -1,5 +1,9 @@ # This file was autogenerated by uv via the following command: # uv pip compile pyproject.toml --extra test --resolution highest --python 3.14 -o requirements-314.txt +astropy==7.2.0 + # via matplot2tikz (pyproject.toml) +astropy-iers-data==0.2026.2.2.0.48.1 + # via astropy colorama==0.4.6 # via pytest contourpy==1.3.3 @@ -21,11 +25,14 @@ matplotlib==3.10.7 numpy==2.3.4 # via # matplot2tikz (pyproject.toml) + # astropy # contourpy # matplotlib # pandas + # pyerfa packaging==25.0 # via + # astropy # matplotlib # pytest pandas==2.3.3 @@ -38,6 +45,8 @@ pluggy==1.6.0 # via # pytest # pytest-cov +pyerfa==2.0.1.5 + # via astropy pygments==2.19.2 # via pytest pyparsing==3.2.5 @@ -54,6 +63,8 @@ python-dateutil==2.9.0.post0 # pandas pytz==2025.2 # via pandas +pyyaml==6.0.3 + # via astropy six==1.17.0 # via python-dateutil typeguard==4.4.4 diff --git a/src/matplot2tikz/__about__.py b/src/matplot2tikz/__about__.py index 2116ce92..05396b0c 100644 --- a/src/matplot2tikz/__about__.py +++ b/src/matplot2tikz/__about__.py @@ -1,3 +1,3 @@ """Version number.""" -__version__ = "0.5.1" +__version__ = "0.5.2" diff --git a/src/matplot2tikz/_save.py b/src/matplot2tikz/_save.py index 0bb0c1c2..5159680a 100644 --- a/src/matplot2tikz/_save.py +++ b/src/matplot2tikz/_save.py @@ -391,6 +391,10 @@ def _recurse(data: TikzData, obj: Artist) -> list: if isinstance(child, (Spine, XAxis, YAxis)): continue + # Skip WCS axes artist - it's a placeholder with no visible content + if type(child).__name__ == "_WCSAxesArtist": + continue + if isinstance(child, Axes): _process_axes(data, child, content) diff --git a/tests/test_wcs_axes.py b/tests/test_wcs_axes.py new file mode 100644 index 00000000..844f9046 --- /dev/null +++ b/tests/test_wcs_axes.py @@ -0,0 +1,62 @@ +"""Test plot with WCS axes.""" + +import warnings + +import matplotlib as mpl +import matplotlib.pyplot as plt +import numpy as np +from astropy.wcs import WCS + +import matplot2tikz + +mpl.use("Agg") + + +def test_wcs_axes() -> None: + """Test that WCS axes are handled without warnings.""" + # Create a simple WCS + wcs = WCS(naxis=2) + wcs.wcs.crpix = [50, 50] + wcs.wcs.cdelt = [0.1, 0.1] + wcs.wcs.crval = [0, -90] + wcs.wcs.ctype = ["RA---TAN", "DEC--TAN"] + + # Create a figure with WCS projection + fig, ax = plt.subplots(subplot_kw={"projection": wcs}) + + # Add some data + rng = np.random.default_rng(1337) + data = rng.integers(5, size=(2, 4)) + vmin = data.min() + vmax = data.max() + mappable = ax.imshow(data, vmin=vmin, vmax=vmax, origin="lower", cmap="viridis") + ax.grid(color="white", ls="solid", alpha=0.5) + ax.set(xlabel="Galactic Longitude", ylabel="Galactic Latitude") + _ = fig.colorbar(mappable, ax=ax, label="Test Unit") + + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + tikz_code = matplot2tikz.get_tikz_code() + + # Filter warnings to only check for the specific warning about unknown objects + unknown_object_warnings = [ + warning + for warning in w + if issubclass(warning.category, UserWarning) + and "Don't know how to handle object" in str(warning.message) + and "_WCSAxesArtist" in str(warning.message) + ] + + # Assert that we didn't get the _WCSAxesArtist warning + assert len(unknown_object_warnings) == 0, ( + f"Got unexpected warning about _WCSAxesArtist: " + f"{[str(warning.message) for warning in unknown_object_warnings]}" + ) + + # Basic checks that the output looks reasonable + assert "\\begin{tikzpicture}" in tikz_code + assert "\\end{tikzpicture}" in tikz_code + # Check that image is included + assert "\\addplot graphics" in tikz_code + + plt.close("all")