Skip to content

Commit d3dba08

Browse files
author
Carwyn Pelley
committed
BUG: Fixed object type missmatch in SymLogNorm
Currently SymLogNorm accepts both linthresh and vmin, vmax with their native dtype, meaning that the contents of one object cannot be updated with another due to a mismatch of types.
1 parent 7a9f234 commit d3dba08

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/matplotlib/colors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ def __init__(self, linthresh, linscale=1.0,
10541054
the logarithmic range. Defaults to 1.
10551055
"""
10561056
Normalize.__init__(self, vmin, vmax, clip)
1057-
self.linthresh = linthresh
1057+
self.linthresh = float(linthresh)
10581058
self._linscale_adj = (linscale / (1.0 - np.e ** -1))
10591059

10601060
def __call__(self, value, clip=None):
@@ -1112,7 +1112,7 @@ def _transform_vmin_vmax(self):
11121112
Calculates vmin and vmax in the transformed system.
11131113
"""
11141114
vmin, vmax = self.vmin, self.vmax
1115-
arr = np.array([vmax, vmin])
1115+
arr = np.array([vmax, vmin]).astype(np.float)
11161116
self._upper, self._lower = self._transform(arr)
11171117

11181118
def inverse(self, value):

lib/matplotlib/tests/test_colors.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ def test_SymLogNorm():
7575
_scalar_tester(norm, vals)
7676
_mask_tester(norm, vals)
7777

78+
# Ensure that specifying vmin returns the same result as above
79+
norm = mcolors.SymLogNorm(3, vmin=-30, vmax=5, linscale=1.2)
80+
normed_vals = norm(vals)
81+
assert_array_almost_equal(normed_vals, expected)
82+
7883

7984
def _inverse_tester(norm_instance, vals):
8085
"""

0 commit comments

Comments
 (0)