Repository: mathause/mplotutils

Issue:
deprecate infer_interval_breaks
This is no longer needed with new matplotlib versions (check from which versions on). So these functions should be removed.

https://github.com/mathause/mplotutils/blob/b9048b86b8758a31b4462c589b2921899ae45fc4/mplotutils/cartopy_utils.py#L40

Discussion:

Patch:
diff --git a/.github/workflows/ci-additional.yaml b/.github/workflows/ci-additional.yaml
index 7708b84..c8119a1 100644
--- a/.github/workflows/ci-additional.yaml
+++ b/.github/workflows/ci-additional.yaml
@@ -83,7 +83,7 @@ jobs:
           fetch-depth: 0 # Fetch all history for all branches and tags.
 
       - name: Create conda environment
-        uses: mamba-org/provision-with-micromamba@main
+        uses: mamba-org/provision-with-micromamba@v14
         with:
           environment-name: min-version-policy
           environment-file: false
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index b9bdfac..0fbda42 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -33,7 +33,7 @@ jobs:
           echo "CONDA_ENV_FILE=ci/requirements/environment.yml" >> $GITHUB_ENV
           echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
       - name: Create conda environment
-        uses: mamba-org/provision-with-micromamba@main
+        uses: mamba-org/provision-with-micromamba@v14
         with:
           cache-downloads: true
           cache-downloads-key: "${{runner.os}}-${{runner.arch}}-py${{matrix.python-version}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c0771f3..534df9e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,11 @@
 
 ## v0.3.0 (unreleased)
 
+### Deprecations
+
+ * Deprecated `mpu.infer_interval_breaks` as this is no longer necessary with matplotlib v3.2
+   and cartopy v0.21 [#32](https://github.com/mathause/mplotutils/pull/32).
+
 ### Bug fixes
 
  * Fixed compatibility of `mpu.colorbar` with `bbox_inches="tight"` for matplotlib 3.4 and
diff --git a/mplotutils/cartopy_utils.py b/mplotutils/cartopy_utils.py
index fd3bd4b..86a517d 100644
--- a/mplotutils/cartopy_utils.py
+++ b/mplotutils/cartopy_utils.py
@@ -1,5 +1,7 @@
 # code by M.Hauser
 
+import warnings
+
 import cartopy.crs as ccrs
 import cartopy.util as cutil
 import matplotlib.pyplot as plt
@@ -40,6 +42,14 @@ def sample_data_map(nlons, nlats):
 def infer_interval_breaks(x, y, clip=False):
     """find edges of gridcells, given their centers"""
 
+    # TODO: require cartopy >= 0.21 when removing this function
+    warnings.warn(
+        "It's no longer necessary to compute the edges of the array. This is now done"
+        "in matplotlib. This function will be removed from mplotutils in a future "
+        "version.",
+        FutureWarning,
+    )
+
     if len(x.shape) == 1:
         x = _infer_interval_breaks(x)
         y = _infer_interval_breaks(y)
diff --git a/requirements.txt b/requirements.txt
index 4962d50..7688f39 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,6 +3,6 @@
 # https://help.github.com/en/github/visualizing-repository-data-with-graphs/listing-the-packages-that-a-repository-depends-on
 
 cartopy >= 0.17
-matplotlib >= 3.2
+matplotlib >= 3.4
 numpy >= 1.17
 setuptools >= 40.4  # for pkg_resources


Test patch:
diff --git a/mplotutils/tests/test_infer_interval_breaks.py b/mplotutils/tests/test_infer_interval_breaks.py
index 48e2505..fb4a3bb 100644
--- a/mplotutils/tests/test_infer_interval_breaks.py
+++ b/mplotutils/tests/test_infer_interval_breaks.py
@@ -1,9 +1,16 @@
 import numpy as np
+import pytest
 from numpy.testing import assert_array_equal  # noqa: F401
 
 from mplotutils.cartopy_utils import _infer_interval_breaks, infer_interval_breaks
 
 
+def test_infer_interval_breaks_warns():
+
+    with pytest.warns(FutureWarning):
+        infer_interval_breaks(np.array([1, 2, 3]), np.array([1, 2, 3]))
+
+
 def test__infer_interval_breaks():
     assert_array_equal([-0.5, 0.5, 1.5], _infer_interval_breaks([0, 1]))
     assert_array_equal(
@@ -26,6 +33,7 @@ def test__infer_interval_breaks():
     #     _infer_interval_breaks(np.array([0, 2, 1]))
 
 
+@pytest.mark.filterwarnings("ignore:It's no longer necessary")
 def test_infer_interval_breaks():
 
     # 1D
@@ -52,6 +60,7 @@ def test_infer_interval_breaks():
     np.testing.assert_allclose(yref, y)
 
 
+@pytest.mark.filterwarnings("ignore:It's no longer necessary")
 def test_infer_interval_breaks_clip():
 
     # no clip
@@ -74,17 +83,3 @@ def test_infer_interval_breaks_clip():
 
     np.testing.assert_allclose(lon_expected, lon_result)
     np.testing.assert_allclose(lat_expected, lat_result)
-
-    # 2D, as above
-
-    # def test_is_monotonic():
-
-    # _is_monotonic(coord, axis=0):
-    """
-    >>> _is_monotonic(np.array([0, 1, 2]))
-    True
-    >>> _is_monotonic(np.array([2, 1, 0]))
-    True
-    >>> _is_monotonic(np.array([0, 2, 1]))
-    False
-    """