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 1b96a31

Browse filesBrowse files
committed
Check vmin/vmax are valid when doing inverse in LogNorm
1 parent dd9bcd5 commit 1b96a31
Copy full SHA for 1b96a31

File tree

Expand file treeCollapse file tree

1 file changed

+9
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-5
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,12 @@ def __call__(self, value, clip=None):
10381038
class LogNorm(Normalize):
10391039
"""Normalize a given value to the 0-1 range on a log scale."""
10401040

1041+
def _check_vmin_vmax(self):
1042+
if self.vmin > self.vmax:
1043+
raise ValueError("minvalue must be less than or equal to maxvalue")
1044+
elif self.vmin <= 0:
1045+
raise ValueError("minvalue must be positive")
1046+
10411047
def __call__(self, value, clip=None):
10421048
if clip is None:
10431049
clip = self.clip
@@ -1047,12 +1053,9 @@ def __call__(self, value, clip=None):
10471053
result = np.ma.masked_less_equal(result, 0, copy=False)
10481054

10491055
self.autoscale_None(result)
1056+
self._check_vmin_vmax()
10501057
vmin, vmax = self.vmin, self.vmax
1051-
if vmin > vmax:
1052-
raise ValueError("minvalue must be less than or equal to maxvalue")
1053-
elif vmin <= 0:
1054-
raise ValueError("values must all be positive")
1055-
elif vmin == vmax:
1058+
if vmin == vmax:
10561059
result.fill(0)
10571060
else:
10581061
if clip:
@@ -1078,6 +1081,7 @@ def __call__(self, value, clip=None):
10781081
def inverse(self, value):
10791082
if not self.scaled():
10801083
raise ValueError("Not invertible until scaled")
1084+
self._check_vmin_vmax()
10811085
vmin, vmax = self.vmin, self.vmax
10821086

10831087
if np.iterable(value):

0 commit comments

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