Call _transform_vmin_vmax during SymLogNorm.__init__ #6780

Merged
merged 4 commits into from Dec 20, 2016

Conversation

Projects
6 participants
Contributor

Salganos commented Jul 17, 2016

A fix for #6750

@Salganos Salganos Call _transform_vmin_vmax during SymLogNorm.__init__
A fix for #6750
00a1559

mdboom added the needs_review label Jul 17, 2016

Owner

tacaswell commented Jul 23, 2016

👍

Can you also add a test? It does not need to be an image test, just the minimal code that would have raised before.

Contributor

Salganos commented Jul 25, 2016 edited

Not sure where to add that, but I'll look into it. The minimal test should be something like:
cb.ColorbarBase(plt.figure().add_subplot(111), norm = clr.SymLogNorm(linthresh = .1, vmin = -1, vmax = 1))

Edit: I think I've found the spot.

@Salganos Salganos Update test_colors.py
0164a41

@tacaswell tacaswell commented on an outdated diff Jul 25, 2016

lib/matplotlib/tests/test_colors.py
@@ -222,6 +223,13 @@ def test_SymLogNorm():
norm = mcolors.SymLogNorm(3, vmin=-30, vmax=5, linscale=1.2)
normed_vals = norm(vals)
assert_array_almost_equal(normed_vals, expected)
+
+ # Ensure that a SymLogNorm object can be used in a colorbar
@tacaswell

tacaswell Jul 25, 2016

Owner

This should be it's own test (any function name that starts with test_ will work).

It also needs the @cleanup decorator.

@Salganos Salganos put SymLogNorm-colorbar test into separate function
7a9130c
Owner

tacaswell commented Jul 26, 2016

❤️ pep8/pycodestyle

There is some trailing white space:

FAIL: matplotlib.tests.test_coding_standards.test_pep8_conformance_installed_files
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/matplotlib/matplotlib/venv/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/tests/test_coding_standards.py", line 244, in test_pep8_conformance_installed_files
    expected_bad_files=expected_bad_files)
  File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/tests/test_coding_standards.py", line 143, in assert_pep8_conformance
    assert_equal(result.total_errors, 0, msg)
AssertionError: 1 != 0 : Found code syntax errors (and warnings):
/home/travis/build/matplotlib/matplotlib/lib/matplotlib/tests/test_colors.py:226:1: W293 blank line contains whitespace

This may seem petty and annoying, but keeping a consistent style (including no trailing white space) really does help on big projects with many contributors.

@Salganos Salganos Fix whitespace
3ec7376
Contributor

Salganos commented Jul 26, 2016

Whoops. The perils of not using a proper development environment.

Contributor

NelleV commented Dec 19, 2016

👍 LGTM

NelleV changed the title from Call _transform_vmin_vmax during SymLogNorm.__init__ to [MRG+1] Call _transform_vmin_vmax during SymLogNorm.__init__ Dec 19, 2016

@NelleV

NelleV approved these changes Dec 19, 2016

@efiring

Apart from the minor suggestion to delete a line from the test, this looks good--it makes sense.

+ 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

NelleV changed the title from [MRG+1] Call _transform_vmin_vmax during SymLogNorm.__init__ to [MRG+2] Call _transform_vmin_vmax during SymLogNorm.__init__ Dec 19, 2016

@tacaswell tacaswell merged commit 58a8334 into matplotlib:master Dec 20, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.02%) to 70.352%
Details
Owner

tacaswell commented Dec 20, 2016

Changed my mind about targeting 2.x . If someone disagrees, I will not protest to it being backported.

Owner

efiring commented Dec 20, 2016

It's not critical, but I am mildly in favor of the backport. The change has no effect in most uses, but blocks a potential failure mode.

Member

QuLogic commented Dec 26, 2016

@efiring Are you going to backport?

Owner

efiring commented Dec 26, 2016

Sure, I can do that in a few minutes.

@efiring efiring added a commit that referenced this pull request Dec 26, 2016

@tacaswell @efiring tacaswell + efiring Merge pull request #6780 from Salganos/Salganos-SymLogNorm
ENH: Call _transform_vmin_vmax during SymLogNorm.__init__
0ab4599
Owner

efiring commented Dec 26, 2016

Backported to v2.x as 0ab4599

QuLogic removed the needs_review label Dec 26, 2016

QuLogic changed the title from [MRG+2] Call _transform_vmin_vmax during SymLogNorm.__init__ to Call _transform_vmin_vmax during SymLogNorm.__init__ Dec 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment