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

Add sym-log normalization. #1355

Merged
merged 2 commits into from Nov 13, 2012
Merged

Add sym-log normalization. #1355

merged 2 commits into from Nov 13, 2012

Conversation

Tillsten
Copy link
Contributor

Added a symmetric log-normalization. Fixed a small bug in LogNorm while on it.

@Tillsten
Copy link
Contributor Author

closes #632

@pelson
Copy link
Member

pelson commented Oct 10, 2012

Thanks for this @Tillsten . Do you have a small test case for this? Would you be willing to add it as a image test?
Additionally, do you have a test case where LogNorm was failing?

Thanks,

Calculates vmin and vmax in the transformed system.
"""
vmin, vmax = self.vmin, self.vmax
if abs(vmin) > self.linthresh:#
Copy link
Member

Choose a reason for hiding this comment

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

There's a # sign, which, I think, is not supposed to me there here.

@dmcdougall
Copy link
Member

That LogNorm bug fix would be nice to get into v1.2.x, which won't happen if it's bundled with this new SymLogNorm feature.

@Tillsten Would you be willing to separate them, creating a new PR for the LogNorm fix? Perhaps I'm missing something and there's a better way of doing this.

@Tillsten
Copy link
Contributor Author

@dmcdougall done in #1362.

@Tillsten
Copy link
Contributor Author

@pelson Will try to make some test tomorrow. Btw they are almost no test for colors.

@Tillsten
Copy link
Contributor Author

Anything else to do? By the way, right now there is a lot of the duplication of functionality in colors and scales, which could be combined.

@@ -4,7 +4,7 @@

from __future__ import print_function
import numpy as np
from numpy.testing.utils import assert_array_equal
from numpy.testing.utils import assert_array_equal, assert_array_approx_equal
Copy link
Member

Choose a reason for hiding this comment

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

This line is making the test_colors script fail.

Copy link
Member

Choose a reason for hiding this comment

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

Aha! Typo. Wow that took much longer than I expected.

It should be from numpy.testing.utils import assert_array_equal, assert_array_almost_equal. You will also need to change the call to this method in the symlog test.

@Tillsten
Copy link
Contributor Author

The issued mentioned are fixed, but i'll also add an functionality to set the ration between the linear- and the logpart, similar to the scale. But that will happen later this week.

@dmcdougall
Copy link
Member

@Tillsten Could you push the fixes? It'd be nice to see the CI server run the tests just as a sanity check.

masked = np.abs(a)> self.linthresh
sign = np.sign(a[masked])
log = sign * self.linthresh \
* (1 + np.log(np.abs(a[masked]) / self.linthresh))
Copy link
Member

Choose a reason for hiding this comment

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

Use of backslash to continue a line is discouraged, as it is not PEP8 compliant. Could you use parentheses to continue the line, or a temporary variable to make the line shorter?

@dmcdougall
Copy link
Member

@Tillsten Could you also add a section to doc/users/whats_new.rst giving yourself credit for your new creation?

Thanks for your hard work.

@Tillsten
Copy link
Contributor Author

Tillsten commented Nov 7, 2012

Oh, thanks for reminding me to finish the PR. Had to do lab stuff and forgot about it :(, sorry

@Tillsten
Copy link
Contributor Author

Tillsten commented Nov 9, 2012

Gna, the handling of scalars is broken i think.

@dmcdougall
Copy link
Member

Perhaps write a test for the scalar case, too?

@Tillsten
Copy link
Contributor Author

i think it is now ready to merge, but maybe there are some style issues left.

if not self.scaled():
raise ValueError("Not invertible until scaled")
val = ma.asarray(value)
val = val*(self._upper-self._lower)+self._lower
Copy link
Member

Choose a reason for hiding this comment

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

Need spaces around mathematical operators

@Tillsten
Copy link
Contributor Author

I really need a pep8 checker for my editor 👍

@dmcdougall
Copy link
Member

@Tillsten Thanks. Looks like @WeatherGod had spotted some PEP8 issues I had missed. Thanks for that.

Would you squash all this down to a single commit?

@Tillsten
Copy link
Contributor Author

Sorry, still learning the git-basics, i think i have done something wrong.

@Tillsten
Copy link
Contributor Author

Ok, now it looks fine.

@dmcdougall
Copy link
Member

You should add an entry in doc/users/whats_new.rst giving yourself credit for your baby.

@Tillsten
Copy link
Contributor Author

Can i just put it into the changelog? I don't think this commit is big enough for the what's new section.

@dmcdougall
Copy link
Member

Sure.

@dmcdougall
Copy link
Member

How do you feel about adding an example to the gallery?

@Tillsten
Copy link
Contributor Author

@dmcdougall That would only make sense in comparison to other norms with addition of an explanation. Maybe i will
such an example after i contributed a symetric norm which i have laying around.

@dmcdougall
Copy link
Member

Is there anything else you wish to add?

@Tillsten
Copy link
Contributor Author

Not for this PR.

dmcdougall added a commit that referenced this pull request Nov 13, 2012
@dmcdougall dmcdougall merged commit c62a6cc into matplotlib:master Nov 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants