-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add sym-log normalization. #1355
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
Conversation
closes #632 |
Thanks for this @Tillsten . Do you have a small test case for this? Would you be willing to add it as a image test? Thanks, |
Calculates vmin and vmax in the transformed system. | ||
""" | ||
vmin, vmax = self.vmin, self.vmax | ||
if abs(vmin) > self.linthresh:# |
There was a problem hiding this comment.
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.
That @Tillsten Would you be willing to separate them, creating a new PR for the |
@dmcdougall done in #1362. |
@pelson Will try to make some test tomorrow. Btw they are almost no test for colors. |
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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. |
@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)) |
There was a problem hiding this comment.
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?
@Tillsten Could you also add a section to Thanks for your hard work. |
Oh, thanks for reminding me to finish the PR. Had to do lab stuff and forgot about it :(, sorry |
Gna, the handling of scalars is broken i think. |
Perhaps write a test for the scalar case, too? |
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 |
There was a problem hiding this comment.
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
I really need a pep8 checker for my editor 👍 |
@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? |
Sorry, still learning the git-basics, i think i have done something wrong. |
Ok, now it looks fine. |
You should add an entry in |
Can i just put it into the changelog? I don't think this commit is big enough for the what's new section. |
Sure. |
How do you feel about adding an example to the gallery? |
@dmcdougall That would only make sense in comparison to other norms with addition of an explanation. Maybe i will |
Is there anything else you wish to add? |
Not for this PR. |
Added a symmetric log-normalization. Fixed a small bug in LogNorm while on it.