From 63bdc4fa381e536df8571aa244d587599bc0d3a5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 18:35:12 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black-pre-commit-mirror: 25.12.0 → 26.1.0](https://github.com/psf/black-pre-commit-mirror/compare/25.12.0...26.1.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c258b9077..232018712 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,6 @@ ci: repos: - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 + rev: 26.1.0 hooks: - id: black From b68d532f6559496f946ca3dd48a68ac355dfa751 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 18:35:52 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/sphinxext/custom_roles.py | 1 + ultraplot/__init__.py | 1 + ultraplot/_lazy.py | 1 + ultraplot/axes/__init__.py | 1 + ultraplot/axes/base.py | 17 +++++++++-------- ultraplot/axes/cartesian.py | 1 + ultraplot/axes/container.py | 1 + ultraplot/axes/geo.py | 1 + ultraplot/axes/plot.py | 1 + ultraplot/axes/plot_types/circlize.py | 1 + ultraplot/axes/polar.py | 1 + ultraplot/axes/shared.py | 1 + ultraplot/axes/three.py | 1 + ultraplot/colors.py | 1 + ultraplot/config.py | 1 + ultraplot/constructor.py | 1 + ultraplot/demos.py | 1 + ultraplot/externals/__init__.py | 1 + ultraplot/externals/hsluv.py | 1 + ultraplot/figure.py | 1 + ultraplot/gridspec.py | 1 + ultraplot/internals/__init__.py | 1 + ultraplot/internals/benchmarks.py | 1 + ultraplot/internals/context.py | 1 + ultraplot/internals/docstring.py | 1 + ultraplot/internals/fonts.py | 1 + ultraplot/internals/guides.py | 1 + ultraplot/internals/inputs.py | 1 + ultraplot/internals/labels.py | 1 + ultraplot/internals/rcsetup.py | 1 + ultraplot/internals/versions.py | 1 + ultraplot/internals/warnings.py | 1 + ultraplot/proj.py | 1 + ultraplot/scale.py | 1 + ultraplot/tests/test_1dplots.py | 1 + ultraplot/tests/test_2dplots.py | 1 + ultraplot/tests/test_axes.py | 1 + ultraplot/tests/test_colorbar.py | 1 + ultraplot/tests/test_docs.py | 1 + .../test_external_axes_container_integration.py | 1 + .../tests/test_external_container_edge_cases.py | 1 + .../tests/test_external_container_mocked.py | 1 + ultraplot/tests/test_format.py | 2 +- ultraplot/tests/test_integration.py | 1 + ultraplot/tests/test_projections.py | 1 + ultraplot/tests/test_subplots.py | 1 + ultraplot/ticker.py | 1 + ultraplot/ui.py | 1 + ultraplot/utils.py | 1 + 49 files changed, 57 insertions(+), 9 deletions(-) diff --git a/docs/sphinxext/custom_roles.py b/docs/sphinxext/custom_roles.py index 2e826c20c..a4d8488e6 100644 --- a/docs/sphinxext/custom_roles.py +++ b/docs/sphinxext/custom_roles.py @@ -2,6 +2,7 @@ """ Custom :rc: and :rcraw: roles for rc settings. """ + import os from docutils import nodes diff --git a/ultraplot/__init__.py b/ultraplot/__init__.py index 297246d5a..01fd0bed6 100644 --- a/ultraplot/__init__.py +++ b/ultraplot/__init__.py @@ -2,6 +2,7 @@ """ A succinct matplotlib wrapper for making beautiful, publication-quality graphics. """ + from __future__ import annotations import sys diff --git a/ultraplot/_lazy.py b/ultraplot/_lazy.py index 502c811d9..7116b9f6a 100644 --- a/ultraplot/_lazy.py +++ b/ultraplot/_lazy.py @@ -2,6 +2,7 @@ """ Helpers for lazy attribute loading in :mod:`ultraplot`. """ + from __future__ import annotations import ast diff --git a/ultraplot/axes/__init__.py b/ultraplot/axes/__init__.py index caed005f8..1c8163dcf 100644 --- a/ultraplot/axes/__init__.py +++ b/ultraplot/axes/__init__.py @@ -2,6 +2,7 @@ """ The various axes classes used throughout ultraplot. """ + import matplotlib.projections as mproj from ..internals import context diff --git a/ultraplot/axes/base.py b/ultraplot/axes/base.py index b4462ed32..dc61d8cc5 100644 --- a/ultraplot/axes/base.py +++ b/ultraplot/axes/base.py @@ -3,6 +3,7 @@ The first-level axes subclass used for all ultraplot figures. Implements basic shared functionality. """ + import copy import inspect import re @@ -4191,8 +4192,8 @@ def _measure_text_overhang_axes( renderer = axes.figure._get_renderer() bbox = text.get_window_extent(renderer=renderer) inv = axes.transAxes.inverted() - (x0, y0) = inv.transform((bbox.x0, bbox.y0)) - (x1, y1) = inv.transform((bbox.x1, bbox.y1)) + x0, y0 = inv.transform((bbox.x0, bbox.y0)) + x1, y1 = inv.transform((bbox.x1, bbox.y1)) except Exception: return None left = max(0.0, -x0) @@ -4218,8 +4219,8 @@ def _measure_ticklabel_overhang_axes( if not label.get_visible() or not label.get_text(): continue bbox = label.get_window_extent(renderer=renderer) - (x0, y0) = inv.transform((bbox.x0, bbox.y0)) - (x1, y1) = inv.transform((bbox.x1, bbox.y1)) + x0, y0 = inv.transform((bbox.x0, bbox.y0)) + x1, y1 = inv.transform((bbox.x1, bbox.y1)) min_x = min(min_x, x0) max_x = max(max_x, x1) min_y = min(min_y, y0) @@ -4595,11 +4596,11 @@ def _reflow_inset_colorbar_frame( x1 = max(b.x1 for b in bboxes) y1 = max(b.y1 for b in bboxes) inv_parent = parent.transAxes.inverted() - (px0, py0) = inv_parent.transform((x0, y0)) - (px1, py1) = inv_parent.transform((x1, y1)) + px0, py0 = inv_parent.transform((x0, y0)) + px1, py1 = inv_parent.transform((x1, y1)) cax_bbox = cax.get_window_extent(renderer=renderer) - (cx0, cy0) = inv_parent.transform((cax_bbox.x0, cax_bbox.y0)) - (cx1, cy1) = inv_parent.transform((cax_bbox.x1, cax_bbox.y1)) + cx0, cy0 = inv_parent.transform((cax_bbox.x0, cax_bbox.y0)) + cx1, cy1 = inv_parent.transform((cax_bbox.x1, cax_bbox.y1)) px0, px1 = sorted((px0, px1)) py0, py1 = sorted((py0, py1)) cx0, cx1 = sorted((cx0, cx1)) diff --git a/ultraplot/axes/cartesian.py b/ultraplot/axes/cartesian.py index 4eff7ae85..e975356e1 100644 --- a/ultraplot/axes/cartesian.py +++ b/ultraplot/axes/cartesian.py @@ -2,6 +2,7 @@ """ The standard Cartesian axes used for most ultraplot figures. """ + import copy import inspect from dataclasses import dataclass, field diff --git a/ultraplot/axes/container.py b/ultraplot/axes/container.py index 56f1dbcb8..028d98b80 100644 --- a/ultraplot/axes/container.py +++ b/ultraplot/axes/container.py @@ -6,6 +6,7 @@ around external axes classes, allowing them to be used within ultraplot's figure system while maintaining their native functionality. """ + import matplotlib.axes as maxes import matplotlib.transforms as mtransforms from matplotlib import cbook, container diff --git a/ultraplot/axes/geo.py b/ultraplot/axes/geo.py index e00862472..c3920f443 100644 --- a/ultraplot/axes/geo.py +++ b/ultraplot/axes/geo.py @@ -2,6 +2,7 @@ """ Axes filled with cartographic projections. """ + from __future__ import annotations import copy diff --git a/ultraplot/axes/plot.py b/ultraplot/axes/plot.py index 83574fb67..74bfde749 100644 --- a/ultraplot/axes/plot.py +++ b/ultraplot/axes/plot.py @@ -3,6 +3,7 @@ The second-level axes subclass used for all ultraplot figures. Implements plotting method overrides. """ + import contextlib import inspect import itertools diff --git a/ultraplot/axes/plot_types/circlize.py b/ultraplot/axes/plot_types/circlize.py index ee14987b6..0b06505e7 100644 --- a/ultraplot/axes/plot_types/circlize.py +++ b/ultraplot/axes/plot_types/circlize.py @@ -2,6 +2,7 @@ """ Helpers for pyCirclize-backed circular plots. """ + from __future__ import annotations import itertools diff --git a/ultraplot/axes/polar.py b/ultraplot/axes/polar.py index 24f72e8c9..bf62e010c 100644 --- a/ultraplot/axes/polar.py +++ b/ultraplot/axes/polar.py @@ -2,6 +2,7 @@ """ Polar axes using azimuth and radius instead of *x* and *y*. """ + import inspect try: diff --git a/ultraplot/axes/shared.py b/ultraplot/axes/shared.py index 8b434645a..6b66c6219 100644 --- a/ultraplot/axes/shared.py +++ b/ultraplot/axes/shared.py @@ -2,6 +2,7 @@ """ An axes used to jointly format Cartesian and polar axes. """ + # NOTE: We could define these in base.py but idea is projection-specific formatters # should never be defined on the base class. Might add to this class later anyway. import numpy as np diff --git a/ultraplot/axes/three.py b/ultraplot/axes/three.py index 957d8fea0..20bb92ddb 100644 --- a/ultraplot/axes/three.py +++ b/ultraplot/axes/three.py @@ -2,6 +2,7 @@ """ The "3D" axes class. """ + from . import base, shared try: diff --git a/ultraplot/colors.py b/ultraplot/colors.py index 51e15210f..cf5992ee5 100644 --- a/ultraplot/colors.py +++ b/ultraplot/colors.py @@ -2,6 +2,7 @@ """ Various colormap classes and colormap normalization classes. """ + # NOTE: To avoid name conflicts between registered colormaps and colors, print # set(uplt.colors._cmap_database) & set(uplt.colors._color_database) whenever # you add new colormaps. v0.8 result is {'gray', 'marine', 'ocean', 'pink'} due diff --git a/ultraplot/config.py b/ultraplot/config.py index e2c71eb84..4ac429af7 100644 --- a/ultraplot/config.py +++ b/ultraplot/config.py @@ -3,6 +3,7 @@ Tools for setting up ultraplot and configuring global settings. See the :ref:`configuration guide ` for details. """ + # NOTE: The matplotlib analogue to this file is actually __init__.py # but it makes more sense to have all the setup actions in a separate file # so the namespace of the top-level module is unpolluted. diff --git a/ultraplot/constructor.py b/ultraplot/constructor.py index 77a448516..dfa39da2e 100644 --- a/ultraplot/constructor.py +++ b/ultraplot/constructor.py @@ -2,6 +2,7 @@ """ T"he constructor functions used to build class instances from simple shorthand arguments. """ + # NOTE: These functions used to be in separate files like crs.py and # ticker.py but makes more sense to group them together to ensure usage is # consistent and so online documentation is easier to understand. Also in diff --git a/ultraplot/demos.py b/ultraplot/demos.py index c535329fb..85b010e6c 100644 --- a/ultraplot/demos.py +++ b/ultraplot/demos.py @@ -2,6 +2,7 @@ """ Functions for displaying colors and fonts. """ + import os import re diff --git a/ultraplot/externals/__init__.py b/ultraplot/externals/__init__.py index c6e92bb5c..f691fb32d 100644 --- a/ultraplot/externals/__init__.py +++ b/ultraplot/externals/__init__.py @@ -2,4 +2,5 @@ """ External utilities adapted for ultraplot. """ + from . import hsluv # noqa: F401 diff --git a/ultraplot/externals/hsluv.py b/ultraplot/externals/hsluv.py index be917e84e..3e28fb7c4 100644 --- a/ultraplot/externals/hsluv.py +++ b/ultraplot/externals/hsluv.py @@ -23,6 +23,7 @@ the `HCL colorspace `__, and the `HSLuv system `__. """ + # Imports. See: https://stackoverflow.com/a/2353265/4970632 # The HLS is actually HCL import math diff --git a/ultraplot/figure.py b/ultraplot/figure.py index d78718112..068a09afd 100644 --- a/ultraplot/figure.py +++ b/ultraplot/figure.py @@ -2,6 +2,7 @@ """ The figure class used for all ultraplot figures. """ + import functools import inspect import os diff --git a/ultraplot/gridspec.py b/ultraplot/gridspec.py index 4b3e1e8eb..5b12fdc34 100644 --- a/ultraplot/gridspec.py +++ b/ultraplot/gridspec.py @@ -2,6 +2,7 @@ """ The gridspec and subplot grid classes used throughout ultraplot. """ + import inspect import itertools import re diff --git a/ultraplot/internals/__init__.py b/ultraplot/internals/__init__.py index 487fef87a..839dd5a45 100644 --- a/ultraplot/internals/__init__.py +++ b/ultraplot/internals/__init__.py @@ -2,6 +2,7 @@ """ Internal utilities. """ + # Import statements import inspect from importlib import import_module diff --git a/ultraplot/internals/benchmarks.py b/ultraplot/internals/benchmarks.py index c75399678..be1e79bcd 100644 --- a/ultraplot/internals/benchmarks.py +++ b/ultraplot/internals/benchmarks.py @@ -2,6 +2,7 @@ """ Utilities for benchmarking ultraplot performance. """ + import time from . import ic # noqa: F401 diff --git a/ultraplot/internals/context.py b/ultraplot/internals/context.py index f429e6898..1159b8e91 100644 --- a/ultraplot/internals/context.py +++ b/ultraplot/internals/context.py @@ -2,6 +2,7 @@ """ Utilities for manging context. """ + from . import ic # noqa: F401 diff --git a/ultraplot/internals/docstring.py b/ultraplot/internals/docstring.py index 650f7726e..39b2938f6 100644 --- a/ultraplot/internals/docstring.py +++ b/ultraplot/internals/docstring.py @@ -2,6 +2,7 @@ """ Utilities for modifying ultraplot docstrings. """ + # WARNING: To check every docstring in the package for # unfilled snippets simply use the following code: # >>> import ultraplot as uplt diff --git a/ultraplot/internals/fonts.py b/ultraplot/internals/fonts.py index cb275573a..be9ea318c 100644 --- a/ultraplot/internals/fonts.py +++ b/ultraplot/internals/fonts.py @@ -2,6 +2,7 @@ """ Overrides related to math fonts. """ + import matplotlib as mpl from matplotlib.font_manager import findfont, ttfFontProperty from matplotlib.mathtext import MathTextParser diff --git a/ultraplot/internals/guides.py b/ultraplot/internals/guides.py index 3567424e1..5b396791d 100644 --- a/ultraplot/internals/guides.py +++ b/ultraplot/internals/guides.py @@ -2,6 +2,7 @@ """ Utilties related to legends and colorbars. """ + import matplotlib.artist as martist import matplotlib.colorbar as mcolorbar import matplotlib.legend as mlegend # noqa: F401 diff --git a/ultraplot/internals/inputs.py b/ultraplot/internals/inputs.py index ef3fe3876..c606e7949 100644 --- a/ultraplot/internals/inputs.py +++ b/ultraplot/internals/inputs.py @@ -2,6 +2,7 @@ """ Utilities for processing input data passed to plotting commands. """ + import functools import sys diff --git a/ultraplot/internals/labels.py b/ultraplot/internals/labels.py index 8b7cb851e..a6d05e4df 100644 --- a/ultraplot/internals/labels.py +++ b/ultraplot/internals/labels.py @@ -2,6 +2,7 @@ """ Utilities related to matplotlib text labels. """ + import matplotlib.patheffects as mpatheffects import matplotlib.text as mtext from matplotlib.font_manager import FontProperties diff --git a/ultraplot/internals/rcsetup.py b/ultraplot/internals/rcsetup.py index e811159a6..dcb79037b 100644 --- a/ultraplot/internals/rcsetup.py +++ b/ultraplot/internals/rcsetup.py @@ -2,6 +2,7 @@ """ Utilities for global configuration. """ + import functools import re from collections.abc import MutableMapping diff --git a/ultraplot/internals/versions.py b/ultraplot/internals/versions.py index 009ab5e95..1d67fd27b 100644 --- a/ultraplot/internals/versions.py +++ b/ultraplot/internals/versions.py @@ -2,6 +2,7 @@ """ Utilities for handling dependencies and version changes. """ + from . import ic # noqa: F401 from . import warnings diff --git a/ultraplot/internals/warnings.py b/ultraplot/internals/warnings.py index f1bb8fb5f..80e32fdeb 100644 --- a/ultraplot/internals/warnings.py +++ b/ultraplot/internals/warnings.py @@ -2,6 +2,7 @@ """ Utilities for internal warnings and deprecations. """ + import functools import re import sys diff --git a/ultraplot/proj.py b/ultraplot/proj.py index 034f2f32e..9b2c0567b 100644 --- a/ultraplot/proj.py +++ b/ultraplot/proj.py @@ -2,6 +2,7 @@ """ Additional cartopy projection classes. """ + import warnings from .internals import ic # noqa: F401 diff --git a/ultraplot/scale.py b/ultraplot/scale.py index 84ba7d14c..8f137168f 100644 --- a/ultraplot/scale.py +++ b/ultraplot/scale.py @@ -2,6 +2,7 @@ """ Various axis `~matplotlib.scale.ScaleBase` classes. """ + import copy import matplotlib.scale as mscale diff --git a/ultraplot/tests/test_1dplots.py b/ultraplot/tests/test_1dplots.py index 50bfdc75b..257da91a0 100644 --- a/ultraplot/tests/test_1dplots.py +++ b/ultraplot/tests/test_1dplots.py @@ -2,6 +2,7 @@ """ Test 1D plotting overrides. """ + import numpy as np import numpy.ma as ma import pandas as pd diff --git a/ultraplot/tests/test_2dplots.py b/ultraplot/tests/test_2dplots.py index a2b75319d..c9e55506a 100644 --- a/ultraplot/tests/test_2dplots.py +++ b/ultraplot/tests/test_2dplots.py @@ -2,6 +2,7 @@ """ Test 2D plotting overrides. """ + import numpy as np import pytest import xarray as xr diff --git a/ultraplot/tests/test_axes.py b/ultraplot/tests/test_axes.py index f1fad637a..27ed331c2 100644 --- a/ultraplot/tests/test_axes.py +++ b/ultraplot/tests/test_axes.py @@ -2,6 +2,7 @@ """ Test twin, inset, and panel axes. """ + import numpy as np import pytest diff --git a/ultraplot/tests/test_colorbar.py b/ultraplot/tests/test_colorbar.py index 3a268ed1c..19fd9c442 100644 --- a/ultraplot/tests/test_colorbar.py +++ b/ultraplot/tests/test_colorbar.py @@ -2,6 +2,7 @@ """ Test colorbars. """ + import numpy as np import pytest diff --git a/ultraplot/tests/test_docs.py b/ultraplot/tests/test_docs.py index a54062d79..09d3bd277 100644 --- a/ultraplot/tests/test_docs.py +++ b/ultraplot/tests/test_docs.py @@ -2,6 +2,7 @@ """ Automatically build pytests from jupytext py:percent documentation files. """ + # import glob # import os diff --git a/ultraplot/tests/test_external_axes_container_integration.py b/ultraplot/tests/test_external_axes_container_integration.py index 234b98ae7..b6b3130bb 100644 --- a/ultraplot/tests/test_external_axes_container_integration.py +++ b/ultraplot/tests/test_external_axes_container_integration.py @@ -5,6 +5,7 @@ These tests verify that the ExternalAxesContainer works correctly with external axes like mpltern.TernaryAxes. """ + import numpy as np import pytest diff --git a/ultraplot/tests/test_external_container_edge_cases.py b/ultraplot/tests/test_external_container_edge_cases.py index 41bb02b02..01c8939f5 100644 --- a/ultraplot/tests/test_external_container_edge_cases.py +++ b/ultraplot/tests/test_external_container_edge_cases.py @@ -5,6 +5,7 @@ These tests cover error handling, edge cases, and integration scenarios without requiring external dependencies. """ + from unittest.mock import Mock, patch import numpy as np diff --git a/ultraplot/tests/test_external_container_mocked.py b/ultraplot/tests/test_external_container_mocked.py index 85fdee26a..bb2c30305 100644 --- a/ultraplot/tests/test_external_container_mocked.py +++ b/ultraplot/tests/test_external_container_mocked.py @@ -5,6 +5,7 @@ These tests verify container behavior without requiring external dependencies like mpltern to be installed. """ + from unittest.mock import MagicMock, Mock, call, patch import numpy as np diff --git a/ultraplot/tests/test_format.py b/ultraplot/tests/test_format.py index 3a45fd66b..72eb83d1a 100644 --- a/ultraplot/tests/test_format.py +++ b/ultraplot/tests/test_format.py @@ -2,10 +2,10 @@ """ Test format and rc behavior. """ + import locale, numpy as np, ultraplot as uplt, pytest import warnings - # def test_colormap_assign(): # """ # Test below line is possible and naming schemes. diff --git a/ultraplot/tests/test_integration.py b/ultraplot/tests/test_integration.py index 7429fafc0..c82fd38d6 100644 --- a/ultraplot/tests/test_integration.py +++ b/ultraplot/tests/test_integration.py @@ -2,6 +2,7 @@ """ Test xarray, pandas, pint, seaborn integration. """ + import numpy as np import pandas as pd import pint diff --git a/ultraplot/tests/test_projections.py b/ultraplot/tests/test_projections.py index 415b56d1c..7784e42ff 100644 --- a/ultraplot/tests/test_projections.py +++ b/ultraplot/tests/test_projections.py @@ -2,6 +2,7 @@ """ Test projection features. """ + import cartopy.crs as ccrs import matplotlib.pyplot as plt import numpy as np, warnings diff --git a/ultraplot/tests/test_subplots.py b/ultraplot/tests/test_subplots.py index cda3f74cd..9025ffd54 100644 --- a/ultraplot/tests/test_subplots.py +++ b/ultraplot/tests/test_subplots.py @@ -2,6 +2,7 @@ """ Test subplot layout. """ + import numpy as np import pytest diff --git a/ultraplot/ticker.py b/ultraplot/ticker.py index ad1da9519..7e98c0491 100644 --- a/ultraplot/ticker.py +++ b/ultraplot/ticker.py @@ -2,6 +2,7 @@ """ Various `~matplotlib.ticker.Locator` and `~matplotlib.ticker.Formatter` classes. """ + import locale import re from fractions import Fraction diff --git a/ultraplot/ui.py b/ultraplot/ui.py index aebc0cad2..1cafa496f 100644 --- a/ultraplot/ui.py +++ b/ultraplot/ui.py @@ -2,6 +2,7 @@ """ The starting point for creating ultraplot figures. """ + import matplotlib.pyplot as plt from . import axes as paxes diff --git a/ultraplot/utils.py b/ultraplot/utils.py index ed70d9cd9..d07edb9a9 100644 --- a/ultraplot/utils.py +++ b/ultraplot/utils.py @@ -2,6 +2,7 @@ """ Various tools that may be useful while making plots. """ + # WARNING: Cannot import 'rc' anywhere in this file or we get circular import # issues. The rc param validators need functions in this file. import functools