Call _transform_vmin_vmax during SymLogNorm.__init__ #6780

Merged
merged 4 commits into from Dec 20, 2016
View
@@ -1054,6 +1054,8 @@ def __init__(self, linthresh, linscale=1.0,
Normalize.__init__(self, vmin, vmax, clip)
self.linthresh = float(linthresh)
self._linscale_adj = (linscale / (1.0 - np.e ** -1))
+ if vmin is not None and vmax is not None:
+ self._transform_vmin_vmax()
def __call__(self, value, clip=None):
if clip is None:
@@ -22,6 +22,7 @@
import matplotlib
import matplotlib.colors as mcolors
import matplotlib.cm as cm
+import matplotlib.colorbar as mcolorbar
import matplotlib.cbook as cbook
import matplotlib.pyplot as plt
from matplotlib.testing.decorators import (image_comparison,
@@ -224,6 +225,17 @@ def test_SymLogNorm():
assert_array_almost_equal(normed_vals, expected)
+@cleanup
+def test_SymLogNorm_colorbar():
+ """
+ Test un-called SymLogNorm in a colorbar.
+ """
+ norm = mcolors.SymLogNorm(0.1, vmin=-1, vmax=1, linscale=1)
+ fig = plt.figure()
+ cbar = mcolorbar.ColorbarBase(fig.add_subplot(111), norm=norm)
+ plt.close(fig)
@efiring

efiring Dec 19, 2016

Owner

I think this close is unnecessary; the @cleanup decorator handles it, doesn't it?

@tacaswell

tacaswell Dec 20, 2016

Owner

It does, but this does not hurt

+
+
def _inverse_tester(norm_instance, vals):
"""
Checks if the inverse of the given normalization is working.