Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upWIP: Add offset normalizer #3858
Conversation
This comment has been minimized.
This comment has been minimized.
@tacaswell I based this off of a master that I pulled down last night. Is that ok? |
This comment has been minimized.
This comment has been minimized.
Yes On Thu, Nov 27, 2014, 11:35 Paul Hobson notifications@github.com wrote:
|
60aaec1
to
37ff5a5
This comment has been minimized.
This comment has been minimized.
You are right about my last comment, but i have still three points: os = OffsetNorm(-5, -2, -1)
x = np.linspace(-6, 6, 100)
abs(x-os.inverse(os(x))).max() #should be zero, but is two This is why my stackoverflow answer (which you probably read before :)) divides by
instead of vmax-vcenter. Second point the class has no docstring. |
This comment has been minimized.
This comment has been minimized.
Yeah. Good points all around. What you you think about |
raise ValueError("Not invertible until scaled") | ||
|
||
vmin = float(self.vmin) | ||
vcenter = float(self.vcenter) |
This comment has been minimized.
This comment has been minimized.
tacaswell
Nov 29, 2014
Member
I think there is a code path that will end up with self.vcenter
to be None
? I think you need to also override autoscale_None
to make sure it gets set.
This comment has been minimized.
This comment has been minimized.
phobson
Nov 30, 2014
Author
Member
@tacaswell yup. Got that written, Will default to half-way in the middle if not specified.
Thought about looking at the signs of vmax and vmin to see if 0 would be a good choice, but I think edge cases of -0.001 and 1000 make that more complicated than it means to be,
|
||
|
||
class SymmetricalNorm(Normalize): | ||
def __init__(self, vmin=None, vmax=None, clip=False): |
This comment has been minimized.
This comment has been minimized.
tacaswell
Nov 29, 2014
Member
I am not really a fan of this class. It will also behave in very strange ways for vmin/vmax of the same sign.
This comment has been minimized.
This comment has been minimized.
Needs documentation and tests that stress the code a bit more. |
This comment has been minimized.
This comment has been minimized.
Hey @Tillsten I really feel like your class you posted on SO is more robust. I don't feel right using it here without you on the commit log. Do you want to pull this branch down and overwrite what I have with your class? |
This comment has been minimized.
This comment has been minimized.
About the tests, happy to beef things about a bit. What do you think about the pattern I'm using with subclassing a base test case? I feel like the whole file could benefit from similar treatment (separate PR,of course). |
This comment has been minimized.
This comment has been minimized.
Here's that SO solution from @Tillsten |
This comment has been minimized.
This comment has been minimized.
@phobsen Just use it, i will hopefully get other commits anyway. If i ever find the free time ... :) |
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
self.vmax = vmax | ||
self.clip = clip | ||
|
||
def __call__(self, value, clip=False): |
This comment has been minimized.
This comment has been minimized.
if self.vcenter is None: | ||
self.vcenter = (self.vmax + self.vmin) * 0.5 | ||
|
||
return None |
This comment has been minimized.
This comment has been minimized.
def setup(self): | ||
self.vals = np.arange(50) | ||
|
||
@nt.raises(ValueError) |
This comment has been minimized.
This comment has been minimized.
tacaswell
Dec 12, 2014
Member
How are these passing on 2.6? I thought the decorator-style raise tests are not available until 2.7... nm, I was confused
This comment has been minimized.
This comment has been minimized.
This looks pretty solid. Left a few picky comments. I am a bit confused by the decorators working on 2.6 and a bit concerned about the test classes as I don't recall seeing them anyplace else in the test suite. |
This comment has been minimized.
This comment has been minimized.
I did. It didn't change anything, though I was working on a janky dev installation of MPL, so I should probably give it another shot. Looking back a existing source code, |
This comment has been minimized.
This comment has been minimized.
Just had an idea in terms of a name for the general case, |
This comment has been minimized.
This comment has been minimized.
It sounds like all this is actually about using a continuous piece-wise linear curve (first-degree spline) as the mapping function. Is that correct? |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
I like that name. On Tue, Jun 30, 2015 at 11:17 PM, Till Stensitzki notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858 TST: add tests for DivergingNorm DOC: add to colors_api.rst
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858 TST: add tests for DivergingNorm DOC: add to colors_api.rst
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858 TST: add tests for DivergingNorm DOC: add to colors_api.rst
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858 TST: add tests for DivergingNorm DOC: add to colors_api.rst DOC: add tutorial FIX: fix extend=both
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858 TST: add tests for DivergingNorm DOC: add to colors_api.rst DOC: add tutorial FIX: fix extend=both
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858 TST: add tests for DivergingNorm DOC: add to colors_api.rst DOC: add tutorial FIX: fix extend=both DOC: add new example
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858 TST: add tests for DivergingNorm DOC: add to colors_api.rst DOC: add tutorial FIX: fix extend=both DOC: add new example
Borrows heavily from @Tillsen's solution found on StackOverflow here: http://goo.gl/RPXMYB Used with his permission dicussesd on Github here: matplotlib#3858 TST: add tests for DivergingNorm DOC: add to colors_api.rst DOC: add tutorial FIX: fix extend=both DOC: add new example
phobson commentedNov 27, 2014
Trying to close #1806
Not currently on a good machine for development, but I think this pretty straight-forward, so hopefully Travis a test runner will suffice...
OffsetNorm
: This let's you set vmin, vcenter, and vmax. The use case for this is when you have data ranging from e.g., -1, to +2, and you want the the white/gray part at 0, but would also like to use the full range of the red scale. So:Next I'll add
SymNorm
, that will look at the absolute values of vmin and vmax to produce: