10000 BUG: Fixed object type missmatch in SymLogNorm · matplotlib/matplotlib@e4b768c · GitHub
[go: up one dir, main page]

Skip to content

Commit e4b768c

Browse files
Carwyn Pelleypelson
Carwyn Pelley
authored andcommitted
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 6d8c067 commit e4b768c

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
@@ -1050,7 +1050,7 @@ def __init__(self, linthresh, linscale=1.0,
10501050
the logarithmic range. Defaults to 1.
10511051
"""
10521052
Normalize.__init__(self, vmin, vmax, clip)
1053-
self.linthresh = linthresh
1053+
self.linthresh = float(linthresh)
10541054
self._linscale_adj = (linscale / (1.0 - np.e ** -1))
10551055

10561056
def __call__(self, value, clip=None):
@@ -1108,7 +1108,7 @@ def _transform_vmin_vmax(self):
11081108
Calculates vmin and vmax in the transformed system.
11091109
"""
11101110
vmin, vmax = self.vmin, self.vmax
1111-
arr = np.array([vmax, vmin])
1111+
arr = np.array([vmax, vmin]).astype(np.float)
11121112
self._upper, self._lower = self._transform(arr)
11131113

11141114
def inverse(self, value):

lib/matplotlib/tests/test_colors.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def test_SymLogNorm():
7272
_scalar_tester(norm, vals)
7373
_mask_tester(norm, vals)
7474

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

7681
def _inverse_tester(norm_instance, vals):
7782
"""

0 commit comments

Comments
 (0)
0