Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b498783

Browse filesBrowse files
committed
Merge pull request #5552 from tacaswell/DEP_contourset_vminmax
Dep contourset vminmax
2 parents 06a08e3 + 4c8205f commit b498783
Copy full SHA for b498783

File tree

Expand file treeCollapse file tree

2 files changed

+37
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+37
-4
lines changed

‎lib/matplotlib/contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/contour.py
+18-4Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import matplotlib.patches as mpatches
2828
import matplotlib.texmanager as texmanager
2929
import matplotlib.transforms as mtrans
30+
from matplotlib.cbook import mplDeprecation
3031

3132
# Import needed for adding manual selection capability to clabel
3233
from matplotlib.blocking_input import BlockingContourLabeler
@@ -1198,6 +1199,20 @@ def _contour_level_args(self, z, args):
11981199
else:
11991200
raise ValueError("Contour levels must be increasing")
12001201

1202+
@property
1203+
def vmin(self):
1204+
warnings.warn("vmin is deprecated and will be removed in 2.2 "
1205+
"and not replaced.",
1206+
mplDeprecation)
1207+
return getattr(self, '_vmin', None)
1208+
1209+
@property
1210+
def vmax(self):
1211+
warnings.warn("vmax is deprecated and will be removed in 2.2 "
1212+
"and not replaced.",
1213+
mplDeprecation)
1214+
return getattr(self, '_vmax', None)
1215+
12011216
def _process_levels(self):
12021217
"""
12031218
Assign values to :attr:`layers` based on :attr:`levels`,
@@ -1207,10 +1222,9 @@ def _process_levels(self):
12071222
a line is a thin layer. No extended levels are needed
12081223
with line contours.
12091224
"""
1210-
# The following attributes are no longer needed, and
1211-
# should be deprecated and removed to reduce confusion.
1212-
self.vmin = np.amin(self.levels)
1213-
self.vmax = np.amax(self.levels)
1225+
# following are deprecated and will be removed in 2.2
1226+
self._vmin = np.amin(self.levels)
1227+
self._vmax = np.amax(self.levels)
12141228

12151229
# Make a private _levels to include extended regions; we
12161230
# want to leave the original levels attribute unchanged.

‎lib/matplotlib/tests/test_contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_contour.py
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,25 @@ def test_contourf_decreasing_levels():
279279
assert_equal(len(w), 2)
280280

281281

282+
@cleanup
283+
def test_vminvmax_warning():
284+
z = [[0.1, 0.3], [0.5, 0.7]]
285+
plt.figure()
286+
cs = plt.contourf(z, [0.0, 1.0])
287+
288+
with warnings.catch_warnings(record=True) as w:
289+
cs.vmin
290+
assert len(w) == 1
291+
assert (str(w[0].message).startswith(
292+
("vmin is deprecated and will be removed in 2.2 ")))
293+
294+
with warnings.catch_warnings(record=True) as w:
295+
cs.vmax
296+
assert len(w) == 1
297+
assert (str(w[0].message).startswith(
298+
("vmax is deprecated and will be removed in 2.2 ")))
299+
300+
282301
if __name__ == '__main__':
283302
import nose
284303
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.