Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94cc465

Browse files
jklymakrcomer
andcommitted
MNT: revert contour deprecations
Co-authored-by: Ruth Comer <[email protected]>
1 parent 691549e commit 94cc465

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations removed in ``contour``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
``contour.allsegs``, ``contour.allkinds``, and ``contour.find_nearest_contour`` are no
5+
longer marked for deprecation.

lib/matplotlib/contour.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -930,12 +930,12 @@ def __init__(self, ax, *args,
930930
", ".join(map(repr, kwargs))
931931
)
932932

933-
allsegs = _api.deprecated("3.8", pending=True)(property(lambda self: [
933+
allsegs = property(lambda self: [
934934
[subp.vertices for subp in p._iter_connected_components()]
935-
for p in self.get_paths()]))
936-
allkinds = _api.deprecated("3.8", pending=True)(property(lambda self: [
935+
for p in self.get_paths()])
936+
allkinds = property(lambda self: [
937937
[subp.codes for subp in p._iter_connected_components()]
938-
for p in self.get_paths()]))
938+
for p in self.get_paths()])
939939
tcolors = _api.deprecated("3.8")(property(lambda self: [
940940
(tuple(rgba),) for rgba in self.to_rgba(self.cvalues, self.alpha)]))
941941
tlinewidths = _api.deprecated("3.8")(property(lambda self: [
@@ -1389,7 +1389,6 @@ def _find_nearest_contour(self, xy, indices=None):
13891389

13901390
return idx_level_min, idx_vtx_min, proj_min
13911391

1392-
@_api.deprecated("3.8")
13931392
def find_nearest_contour(self, x, y, indices=None, pixel=True):
13941393
"""
13951394
Find the point in the contour plot that is closest to ``(x, y)``.

lib/matplotlib/tests/test_contour.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -530,23 +530,19 @@ def test_find_nearest_contour():
530530
img = np.exp(-np.pi * (np.sum((xy - 5)**2, 0)/5.**2))
531531
cs = plt.contour(img, 10)
532532

533-
with pytest.warns(mpl._api.MatplotlibDeprecationWarning):
534-
nearest_contour = cs.find_nearest_contour(1, 1, pixel=False)
533+
nearest_contour = cs.find_nearest_contour(1, 1, pixel=False)
535534
expected_nearest = (1, 0, 33, 1.965966, 1.965966, 1.866183)
536535
assert_array_almost_equal(nearest_contour, expected_nearest)
537536

538-
with pytest.warns(mpl._api.MatplotlibDeprecationWarning):
539-
nearest_contour = cs.find_nearest_contour(8, 1, pixel=False)
537+
nearest_contour = cs.find_nearest_contour(8, 1, pixel=False)
540538
expected_nearest = (1, 0, 5, 7.550173, 1.587542, 0.547550)
541539
assert_array_almost_equal(nearest_contour, expected_nearest)
542540

543-
with pytest.warns(mpl._api.MatplotlibDeprecationWarning):
544-
nearest_contour = cs.find_nearest_contour(2, 5, pixel=False)
541+
nearest_contour = cs.find_nearest_contour(2, 5, pixel=False)
545542
expected_nearest = (3, 0, 21, 1.884384, 5.023335, 0.013911)
546543
assert_array_almost_equal(nearest_contour, expected_nearest)
547544

548-
with pytest.warns(mpl._api.MatplotlibDeprecationWarning):
549-
nearest_contour = cs.find_nearest_contour(2, 5, indices=(5, 7), pixel=False)
545+
nearest_contour = cs.find_nearest_contour(2, 5, indices=(5, 7), pixel=False)
550546
expected_nearest = (5, 0, 16, 2.628202, 5.0, 0.394638)
551547
assert_array_almost_equal(nearest_contour, expected_nearest)
552548

@@ -556,16 +552,13 @@ def test_find_nearest_contour_no_filled():
556552
img = np.exp(-np.pi * (np.sum((xy - 5)**2, 0)/5.**2))
557553
cs = plt.contourf(img, 10)
558554

559-
with pytest.warns(mpl._api.MatplotlibDeprecationWarning), \
560-
pytest.raises(ValueError, match="Method does not support filled contours"):
555+
with pytest.raises(ValueError, match="Method does not support filled contours"):
561556
cs.find_nearest_contour(1, 1, pixel=False)
562557

563-
with pytest.warns(mpl._api.MatplotlibDeprecationWarning), \
564-
pytest.raises(ValueError, match="Method does not support filled contours"):
558+
with pytest.raises(ValueError, match="Method does not support filled contours"):
565559
cs.find_nearest_contour(1, 10, indices=(5, 7), pixel=False)
566560

567-
with pytest.warns(mpl._api.MatplotlibDeprecationWarning), \
568-
pytest.raises(ValueError, match="Method does not support filled contours"):
561+
with pytest.raises(ValueError, match="Method does not support filled contours"):
569562
cs.find_nearest_contour(2, 5, indices=(2, 7), pixel=True)
570563

571564

@@ -825,12 +818,11 @@ def test_allsegs_allkinds():
825818

826819
cs = plt.contour(x, y, z, levels=[0, 0.5])
827820

828-
# Expect two levels, first with 5 segments and the second with 4.
829-
with pytest.warns(PendingDeprecationWarning, match="all"):
830-
for result in [cs.allsegs, cs.allkinds]:
831-
assert len(result) == 2
832-
assert len(result[0]) == 5
833-
assert len(result[1]) == 4
821+
# Expect two levels, the first with 5 segments and the second with 4.
822+
for result in [cs.allsegs, cs.allkinds]:
823+
assert len(result) == 2
824+
assert len(result[0]) == 5
825+
assert len(result[1]) == 4
834826

835827

836828
def test_deprecated_apis():

0 commit comments

Comments
 (0)