Repository navigation
Corrected behavior of 2D alpha array - #1543
Conversation
greglucas
left a comment
There was a problem hiding this comment.
Overall I think this update makes sense. Do you have a test case you can add to show that this does what you are expecting with 2d alpha?
|
Yep, I know what you were getting at and the improvement :) I meant to add that under the |
|
Sure, I'll make a test for the next commit. |
|
Writing a "good" test is harder than I expected. (As always.) My thought was to test select alphas from the output of |
|
You could get the data out of the returned object like: image = ax.imshow(...)
arr = image.get_array()
alpha = image.get_alpha()
assert arr.shape == alpha.shapeThen you can make sure that the regridded data is the shape expected and that alpha is the same shape as that, which is the real issue here I think. You probably don't need an explicit image if you just want to throw in some fake data and some fake alphas that you could test this against too. |
|
I agree that the shape of the alpha array is the issue--- |
|
I didn't realize those methods were undocumented! It looks like other people have run into the issue with a lack of documentation on that class as well: matplotlib/matplotlib#15503 |
greglucas
left a comment
There was a problem hiding this comment.
It looks like CI is failing because the new file you added doesn't have a header. The test should be under a current file and then you won't run into that license failure. Probably under:
https://github.com/SciTools/cartopy/blob/master/lib/cartopy/tests/mpl/test_img_transform.py
or
https://github.com/SciTools/cartopy/blob/master/lib/cartopy/tests/mpl/test_images.py
and then call it test_alpha_2d_reshape or something along those lines so we know what it is trying to test.
Can you squash your commits into a few good commit messages too?
|
I think the rebase worked. (I haven't done it before.) |


Rationale
imshow() does not warp a 2D alpha array; it passes the unwarped alpha array to matplotlib's imshow(), which results in the display of an unwarped image.
Implications
With these changes imshow() passes a warped 2D alpha array.