-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
Fixed categorical coloring of Contours in matplotlib #2259
Conversation
I can't tell if this PR is ready yet, but at a glance it looks good. Happy to merge once you tell me it is ready and the tests are green. |
Can't be ready since the tests aren't green right :-) Locally it seems to pass but Travis isn't happy yet. Will try to figure this out today. |
Could have just been unlucky with transient failures you know... |
The unit test I added is failing. |
5f74236
to
cada665
Compare
cada665
to
921752a
Compare
@@ -213,7 +213,7 @@ def values(cls, dataset, dim, expanded=True, flat=True): | |||
if np.isscalar(values): | |||
if not expanded: | |||
return np.array([values]) | |||
values = np.full(len(dataset), values) | |||
values = np.full(len(dataset), values, dtype=np.array(values).dtype) |
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 is the most bizarre bug I've come across in a long time. Before I added this dtype
approach this line would error (but only on Travis), given this input:np.full(10, 'B')
, saying that:
ValueError: could not convert string to float: 'B'
But internally np.full
does exactly the same thing I've now done here to fix it:
def full(shape, fill_value, dtype=None, order='C'):
if dtype is None:
dtype = array(fill_value).dtype
a = empty(shape, dtype, order)
multiarray.copyto(a, fill_value, casting='unsafe')
return a
Absolutely baffling, but it seems to work now.
Ready now. |
Weird 'fix'! Anyway, looks good. Merging. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
As the title says, Contours/Polygons in matplotlib did not handle categorical values for the
color_index
.