Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,9 +935,11 @@ def __init__(self, ax, *args,
)

allsegs = _api.deprecated("3.8", pending=True)(property(lambda self: [
p.vertices for c in self.collections for p in c.get_paths()]))
[subp.vertices for subp in p._iter_connected_components()]
for p in self.get_paths()]))
allkinds = _api.deprecated("3.8", pending=True)(property(lambda self: [
p.codes for c in self.collections for p in c.get_paths()]))
[subp.codes for subp in p._iter_connected_components()]
for p in self.get_paths()]))
tcolors = _api.deprecated("3.8")(property(lambda self: [
(tuple(rgba),) for rgba in self.to_rgba(self.cvalues, self.alpha)]))
tlinewidths = _api.deprecated("3.8")(property(lambda self: [
Expand Down
18 changes: 14 additions & 4 deletions lib/matplotlib/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,24 @@ def test_all_nan():
2.4e-14, 5e-14, 7.5e-14, 1e-13])


def test_allsegs_allkinds():
x, y = np.meshgrid(np.arange(0, 10, 2), np.arange(0, 10, 2))
z = np.sin(x) * np.cos(y)

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

# Expect two levels, first with 5 segments and the second with 4.
with pytest.warns(PendingDeprecationWarning, match="all"):
for result in [cs.allsegs, cs.allkinds]:
assert len(result) == 2
assert len(result[0]) == 5
assert len(result[1]) == 4


def test_deprecated_apis():
cs = plt.contour(np.arange(16).reshape((4, 4)))
with pytest.warns(mpl.MatplotlibDeprecationWarning, match="collections"):
colls = cs.collections
with pytest.warns(PendingDeprecationWarning, match="allsegs"):
assert cs.allsegs == [p.vertices for c in colls for p in c.get_paths()]
with pytest.warns(PendingDeprecationWarning, match="allkinds"):
assert cs.allkinds == [p.codes for c in colls for p in c.get_paths()]
with pytest.warns(mpl.MatplotlibDeprecationWarning, match="tcolors"):
assert_array_equal(cs.tcolors, [c.get_edgecolor() for c in colls])
with pytest.warns(mpl.MatplotlibDeprecationWarning, match="tlinewidths"):
Expand Down