Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fixed object type missmatch in SymLogNorm #2428

Merged
merged 1 commit into from Oct 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/colors.py
Expand Up @@ -1054,7 +1054,7 @@ def __init__(self, linthresh, linscale=1.0,
the logarithmic range. Defaults to 1.
"""
Normalize.__init__(self, vmin, vmax, clip)
self.linthresh = linthresh
self.linthresh = float(linthresh)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not np.float?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your interest @pelson

Why not np.float?

No reason, why np.float?
consistency?

>>> type(np.float(3)) <type 'float'>

self._linscale_adj = (linscale / (1.0 - np.e ** -1))

def __call__(self, value, clip=None):
Expand Down Expand Up @@ -1112,7 +1112,7 @@ def _transform_vmin_vmax(self):
Calculates vmin and vmax in the transformed system.
"""
vmin, vmax = self.vmin, self.vmax
arr = np.array([vmax, vmin])
arr = np.array([vmax, vmin]).astype(np.float)
self._upper, self._lower = self._transform(arr)

def inverse(self, value):
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/tests/test_colors.py
Expand Up @@ -75,6 +75,11 @@ def test_SymLogNorm():
_scalar_tester(norm, vals)
_mask_tester(norm, vals)

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a main level function, so we only put one return between definitions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pelson, sry I'm not quite sure I understand. Do you mean that you would like this in its own separate function?
Should this then be called from test_SymLogNorm still? This added test does not use the same instance of SymLogNorm so I'm guessing you would prefer an independent function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have been more clear. PEP8 states that there should be just one newline between methods http://www.python.org/dev/peps/pep-0008/#blank-lines, but re-reading the code it turns out that these are indeed main level functions. My apologies.


def _inverse_tester(norm_instance, vals):
"""
Expand Down