Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Re-write sym-log-norm#16391
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Re-write sym-log-norm#16391
Changes fromall commits
73ae1d3
943a848
60f0d69
6fdd2e0
cc1fa93
8904654
3fb1dcf
82052d8
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -395,22 +395,48 @@ def test_TwoSlopeNorm_premature_scaling(): | ||
def test_SymLogNorm(): | ||
# Test SymLogNorm behavior | ||
norm = mcolors.SymLogNorm(linthresh=3, vmax=5, linscale=1.2, base=np.e) | ||
vals = np.array([-30, -1, 2, 6], dtype=float) | ||
normed_vals = norm(vals) | ||
expected = [-0.842119, 0.450236, 0.599528, 1.277676] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think these values were just plain wrong before...
| ||
assert_array_almost_equal(normed_vals, expected) | ||
_inverse_tester(norm, vals) | ||
_scalar_tester(norm, vals) | ||
_mask_tester(norm, vals) | ||
def test_symlognorm_vals(): | ||
vals = [-10, -1, 0, 1, 10] | ||
norm = mcolors.SymLogNorm(linthresh=1, vmin=-10, vmax=10, linscale=1) | ||
normed_vals = norm(vals) | ||
expected = [0, 0.25, 0.5, 0.75, 1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't think this is consistent with importmatplotlib.scaleasmscaletrans=mscale.SymmetricalLogTransform(10,1,1)new=trans.transform([-10,-1,0,1,10])new= (new-new[0])/ (new[-1]-new[0])print(new)
I'm fine if this implementation is desired, but then we need to change | ||
assert_array_almost_equal(norm(vals), normed_vals) | ||
assert_array_almost_equal(norm.inverse(norm(vals)), vals) | ||
# If we increase linscale to 2, the space for the linear range [0, 1] | ||
# should be twice as large as the space for the logarithmic range [1, 10] | ||
norm = mcolors.SymLogNorm(linthresh=1, vmin=-10, vmax=10, linscale=2) | ||
normed_vals = norm(vals) | ||
expected = [0, 1/6, 0.5, 5/6, 1] | ||
assert_array_almost_equal(norm(vals), normed_vals) | ||
assert_array_almost_equal(norm.inverse(norm(vals)), vals) | ||
# Similarly, going the other way means the linear range should shrink | ||
norm = mcolors.SymLogNorm(linthresh=1, vmin=-10, vmax=10, linscale=0.5) | ||
normed_vals = norm(vals) | ||
expected = [0, 2/6, 0.5, 4/6, 1] | ||
assert_array_almost_equal(norm(vals), normed_vals) | ||
assert_array_almost_equal(norm.inverse(norm(vals)), vals) | ||
# Now check a different base to base 10 | ||
vals = [-8, 4, -2, 0, 2, 4, 8] | ||
norm = mcolors.SymLogNorm(linthresh=2, vmax=8, linscale=1, base=2) | ||
normed_vals = norm(vals) | ||
expected = [0, 1/8, 2/8, 3/8, 0.5, 5/8, 6/8, 7/8, 1] | ||
assert_array_almost_equal(norm(vals), normed_vals) | ||
assert_array_almost_equal(norm.inverse(norm(vals)), vals) | ||
def test_SymLogNorm_colorbar(): | ||
@@ -907,7 +933,7 @@ def __add__(self, other): | ||
for norm in [mcolors.Normalize(), mcolors.LogNorm(), | ||
mcolors.SymLogNorm(3, vmax=5, linscale=1), | ||
mcolors.Normalize(vmin=mydata.min(), vmax=mydata.max()), | ||
mcolors.SymLogNorm(3, vmin=-10, vmax=10), | ||
mcolors.PowerNorm(1)]: | ||
assert_array_equal(norm(mydata), norm(data)) | ||
fig, ax = plt.subplots() | ||