From e6418dd589ac8d2f8e3a208a3912f4297ab6717b Mon Sep 17 00:00:00 2001 From: Mathias Hauser Date: Mon, 4 Nov 2024 11:13:44 +0100 Subject: [PATCH] make modules private (#141) * make modules private * fix import * changelog --- CHANGELOG.md | 2 ++ mplotutils/__init__.py | 22 +++++++++---------- .../{cartopy_utils.py => _cartopy_utils.py} | 2 +- mplotutils/{colormaps.py => _colormaps.py} | 0 mplotutils/_hatch.py | 2 +- mplotutils/{map_layout.py => _map_layout.py} | 2 +- mplotutils/{mpl.py => _mpl.py} | 0 mplotutils/{xrcompat.py => _xrcompat.py} | 0 .../tests/test_infer_interval_breaks.py | 2 +- mplotutils/tests/test_maybe_gca.py | 2 +- 10 files changed, 18 insertions(+), 16 deletions(-) rename mplotutils/{cartopy_utils.py => _cartopy_utils.py} (99%) rename mplotutils/{colormaps.py => _colormaps.py} (100%) rename mplotutils/{map_layout.py => _map_layout.py} (99%) rename mplotutils/{mpl.py => _mpl.py} (100%) rename mplotutils/{xrcompat.py => _xrcompat.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 321454e..c503f89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ | seaborn | 0.12 | 0.13 | | xarray | 2022.12| 2023.9 | +- The modules ``cartopy_utils``, ``colormaps``, ``map_layout``, ``mpl``, and ``xrcompat`` were renamed (added a leading underscore) to indicate that they are private ([#141](https://github.com/mathause/mplotutils/pull/141)). + ### Enhancements - Added convenience functions to draw hatches and add stippling: diff --git a/mplotutils/__init__.py b/mplotutils/__init__.py index f235acb..a5a26be 100644 --- a/mplotutils/__init__.py +++ b/mplotutils/__init__.py @@ -2,11 +2,8 @@ from importlib.metadata import version as _get_version -from mplotutils import _colorbar, cartopy_utils, colormaps -from mplotutils._colorbar import colorbar -from mplotutils._hatch import hatch, hatch_map, hatch_map_global -from mplotutils._savefig import autodraw -from mplotutils.cartopy_utils import ( +from mplotutils import _cartopy_utils, _colorbar, _colormaps +from mplotutils._cartopy_utils import ( cyclic_dataarray, sample_data_map, sample_dataarray, @@ -15,10 +12,13 @@ ylabel_map, yticklabels, ) -from mplotutils.colormaps import from_levels_and_cmap -from mplotutils.map_layout import set_map_layout -from mplotutils.mpl import _get_renderer -from mplotutils.xrcompat import infer_interval_breaks +from mplotutils._colorbar import colorbar +from mplotutils._colormaps import from_levels_and_cmap +from mplotutils._hatch import hatch, hatch_map, hatch_map_global +from mplotutils._map_layout import set_map_layout +from mplotutils._mpl import _get_renderer +from mplotutils._savefig import autodraw +from mplotutils._xrcompat import infer_interval_breaks autodraw(True) @@ -26,9 +26,9 @@ "_colorbar", "_get_renderer", "autodraw", - "cartopy_utils", + "_cartopy_utils", "colorbar", - "colormaps", + "_colormaps", "cyclic_dataarray", "from_levels_and_cmap", "hatch_map_global", diff --git a/mplotutils/cartopy_utils.py b/mplotutils/_cartopy_utils.py similarity index 99% rename from mplotutils/cartopy_utils.py rename to mplotutils/_cartopy_utils.py index b16c6cb..ecbb92e 100644 --- a/mplotutils/cartopy_utils.py +++ b/mplotutils/_cartopy_utils.py @@ -6,8 +6,8 @@ import shapely.geometry from cartopy.mpl.gridliner import LATITUDE_FORMATTER, LONGITUDE_FORMATTER +from mplotutils._colormaps import _get_label_attr from mplotutils._deprecate import _deprecate_positional_args -from mplotutils.colormaps import _get_label_attr def sample_data_map(nlons, nlats): diff --git a/mplotutils/colormaps.py b/mplotutils/_colormaps.py similarity index 100% rename from mplotutils/colormaps.py rename to mplotutils/_colormaps.py diff --git a/mplotutils/_hatch.py b/mplotutils/_hatch.py index 53cdec6..503db36 100644 --- a/mplotutils/_hatch.py +++ b/mplotutils/_hatch.py @@ -10,7 +10,7 @@ _HATCHES_PER_FIGURE = {} -from mplotutils.mpl import _maybe_gca +from mplotutils._mpl import _maybe_gca def hatch(da, hatch, *, ax=None, label=None, linewidth=None, color="0.1"): diff --git a/mplotutils/map_layout.py b/mplotutils/_map_layout.py similarity index 99% rename from mplotutils/map_layout.py rename to mplotutils/_map_layout.py index fa2232a..71e17f0 100644 --- a/mplotutils/map_layout.py +++ b/mplotutils/_map_layout.py @@ -6,7 +6,7 @@ from mpl_toolkits.axes_grid1 import AxesGrid from mplotutils._deprecate import _deprecate_positional_args -from mplotutils.mpl import _get_renderer +from mplotutils._mpl import _get_renderer @_deprecate_positional_args("0.3") diff --git a/mplotutils/mpl.py b/mplotutils/_mpl.py similarity index 100% rename from mplotutils/mpl.py rename to mplotutils/_mpl.py diff --git a/mplotutils/xrcompat.py b/mplotutils/_xrcompat.py similarity index 100% rename from mplotutils/xrcompat.py rename to mplotutils/_xrcompat.py diff --git a/mplotutils/tests/test_infer_interval_breaks.py b/mplotutils/tests/test_infer_interval_breaks.py index 3e2d550..affae52 100644 --- a/mplotutils/tests/test_infer_interval_breaks.py +++ b/mplotutils/tests/test_infer_interval_breaks.py @@ -2,7 +2,7 @@ import pytest from numpy.testing import assert_array_equal # noqa: F401 -from mplotutils.xrcompat import _infer_interval_breaks, infer_interval_breaks +from mplotutils._xrcompat import _infer_interval_breaks, infer_interval_breaks def test_infer_interval_breaks_warns(): diff --git a/mplotutils/tests/test_maybe_gca.py b/mplotutils/tests/test_maybe_gca.py index 8c3eed9..7377b90 100644 --- a/mplotutils/tests/test_maybe_gca.py +++ b/mplotutils/tests/test_maybe_gca.py @@ -1,7 +1,7 @@ import matplotlib as mpl import matplotlib.pyplot as plt -from mplotutils.mpl import _maybe_gca +from mplotutils._mpl import _maybe_gca from . import figure_context