8000 Dep contourset vminmax by tacaswell · Pull Request #5552 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Dep contourset vminmax #5552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 24, 2015
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
22 changes: 18 additions & 4 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import matplotlib.patches as mpatches
import matplotlib.texmanager as texmanager
import matplotlib.transforms as mtrans
from matplotlib.cbook import mplDeprecation

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

@property
def vmin(self):
warnings.warn("vmin is deprecated and will be removed in 2.2 "
"and not replaced.",
mplDeprecation)
return getattr(self, '_vmin', None)

@property
def vmax(self):
warnings.warn("vmax is deprecated and will be removed in 2.2 "
"and not replaced.",
mplDeprecation)
return getattr(self, '_vmax', None)

def _process_levels(self):
"""
Assign values to :attr:`layers` based on :attr:`levels`,
Expand All @@ -1207,10 +1222,9 @@ def _process_levels(self):
a line is a thin layer. No extended levels are needed
with line contours.
"""
# The following attributes are no longer needed, and
# should be deprecated and removed to reduce confusion.
self.vmin = np.amin(self.levels)
self.vmax = np.amax(self.levels)
# following are deprecated and will be removed in 2.2
self._vmin = np.amin(self.levels)
self._vmax = np.amax(self.levels)

# Make a private _levels to include extended regions; we
# want to leave the original levels attribute unchanged.
Expand Down
19 changes: 19 additions & 0 deletions lib/matplotlib/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,25 @@ def test_contourf_decreasing_levels():
assert_equal(len(w), 2)


@cleanup
def test_vminvmax_warning():
z = [[0.1, 0.3], [0.5, 0.7]]
plt.figure()
cs = plt.contourf(z, [0.0, 1.0])

with warnings.catch_warnings(record=True) as w:
cs.vmin
assert len(w) == 1
assert (str(w[0].message).startswith(
("vmin is deprecated and will be removed in 2.2 ")))

with warnings.catch_warnings(record=True) as w:
cs.vmax
assert len(w) == 1
assert (str(w[0].message).startswith(
("vmax is deprecated and will be removed in 2.2 ")))


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
0