Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[MRG+1] Fix imshow masked interpolation#8024

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

tacaswell
Copy link
Member

Closes#8012

The code changes are in the first commit, the image changes are in the second.

This probably needs some more tests and docs. I suspect there is at least one more 🐉 down here...

attn@mdboom

@tacaswelltacaswell added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelFeb 5, 2017
@tacaswelltacaswell added this to the2.0.1 (next bug fix release) milestoneFeb 5, 2017
@tacaswell
Copy link
MemberAuthor

So, defiantly 🐲 in up-sampling when mixing masking + over/under with in the kernel foot print.

importmatplotlib.pyplotaspltimportmatplotlibasmplimportmatplotlib.colorsasmcolorsimportmatplotlib.imageasmimageimportmatplotlib.cmasmcmimportnumpyasnpimportcopycm=copy.copy(mcm.get_cmap('viridis'))cm.set_over('r')cm.set_under('b')cm.set_bad('k')n=mcolors.Normalize(vmin=0,vmax=100)data=np.arange(100,dtype='float').reshape(10,10)data[5,5]=-1data[7,7]=101data[3,3]=np.nandata[5,3]=np.infmask=np.zeros_like(data).astype('bool')mask[3,5]=Truedata=np.ma.masked_array(data,mask)fig,ax_grid=plt.subplots(3,6)forinterp,axinzip(mimage._interpd_,ax_grid.ravel()):ax.set_title(interp)im=ax.imshow(data,norm=n,cmap=cm,interpolation=interp)

so

@tacaswell
Copy link
MemberAuthor

Right, forget about the topo failure, that is due to the resample vs not resample change and I have not looked into it yet.

@tacaswelltacaswellforce-pushed thefix_ishow_masked_interpolation branch 2 times, most recently from8786852 to236b48fCompareFebruary 6, 2017 01:02
@tacaswell
Copy link
MemberAuthor

On the bright side I have managed to fix this without having to change classic style and only update 1 test image, on the down side, one test is still broken.

@tacaswell
Copy link
MemberAuthor

and I have fixed the checker-board effect in that png above, that was due to Agg's aggressive clipping.

@tacaswelltacaswellforce-pushed thefix_ishow_masked_interpolation branch from236b48f to5e83b93CompareFebruary 6, 2017 02:05
@tacaswelltacaswell reopened thisFeb 6, 2017
@tacaswell
Copy link
MemberAuthor

Of course this passes locally...

@tacaswelltacaswellforce-pushed thefix_ishow_masked_interpolation branch 2 times, most recently froma1fbee5 to73091acCompareFebruary 6, 2017 13:23
When determining which pixels to mask in the resampled image, if _any_contribution to final value comes from a masked pixel, mask theresult.Due to Agg special-casing the meaning of the alpha channel,the interpolation for the mask channel needs to be done separately.This is probably a template for doing the over/under separately.print out exact hash on travis
@tacaswelltacaswellforce-pushed thefix_ishow_masked_interpolation branch from73091ac to1a7c4efCompareFebruary 6, 2017 20:22
@@ -76,6 +76,7 @@ before_install:

install:
- ccache -s
- git describe
Copy link
Member

Choose a reason for hiding this comment

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

I'm not concerned about this, but would like to make sure that you intended to have this here.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I did, was a bit worried that gh/travis were having caching / timeout issues and not running the code I thought it was running (turns out the problem is I had accidentally depended on dictionary ordering in 3.6). I think this is a good idea to keep around so that we can verifyexactly what code travis runs for testing locally (it should be running on the merge into the target branch, when it re-sets what that merge is is not something I fully understand yet).

@QuLogicQuLogic changed the titleFix ishow masked interpolationFix imshow masked interpolationFeb 6, 2017
@QuLogic
Copy link
Member

The CI failure appears non-transient.

@dopplershift
Copy link
Contributor

What happened to Appveyor?

@QuLogic
Copy link
Member

It doesn't run on thev2.0.x branch.

@dopplershift
Copy link
Contributor

How did I not know that?

Copy link
Contributor

@dopplershiftdopplershift left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. Only a minor question.

# 'unshare' the mask array to
# needed to suppress numpy warning
del out_mask
invalid_mask = ~output.mask * ~np.isnan(output.data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would& work here instead of*? Would make more sense given the boolean masks.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Are there performance rather than semantic advantages? I think~(a & b) would also work and have one less temprorary.


fig, ax_grid = plt.subplots(3, 6)
for interp, ax in zip(sorted(mimage._interpd_), ax_grid.ravel()):
ax.set_title(interp)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think there's any point adding a title ifremove_text isTrue in the decorator. Otherwise this patch looks good to me.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The title is there for human debuggers later (I often copy-past tests into another buffer and just run them)

Copy link
Member

Choose a reason for hiding this comment

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

👍

for interp, ax in zip(sorted(mimage._interpd_), ax_grid.ravel()):
ax.set_title(interp)
ax.imshow(data, norm=n, cmap=cm, interpolation=interp)
ax.axis('off')
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, prseumably pointless withremove_text == True

@dstansbydstansby changed the titleFix imshow masked interpolation[MRG+1] Fix imshow masked interpolationFeb 24, 2017
@NelleVNelleV merged commit067f9b6 intomatplotlib:v2.0.xFeb 24, 2017
@tacaswelltacaswell deleted the fix_ishow_masked_interpolation branchFebruary 24, 2017 22:30
@tacaswelltacaswell mentioned this pull requestFeb 24, 2017
@QuLogic
Copy link
Member

QuLogic commentedFeb 24, 2017
edited
Loading

This makes for an ugly change in Cartopy:
v2.0.0:
regrid_image
vs v2.0.x:
result-regrid_image
and diff:
result-regrid_image-failed-diff

You might need to view the full resolution image, but it's pretty evident on the lower-most blue one. It used to match the outline, but now there's a very obvious not very straight white bit along the edge.

@dopplershift
Copy link
Contributor

sigh

@QuLogic
Copy link
Member

The build also failedmatplotlib.tests.test_image.test_rotate_image.test on 2.7 and 3.4 when this got merged, though I'm not sure why. This wasn't a troublesome test before.

@QuLogic
Copy link
Member

Even weirder,#8144 is failling on that test on 3.5 but not other versions, even after a rebuild...

@tacaswell
Copy link
MemberAuthor

The rotate image test did give me trouble when working on this.

@tacaswell
Copy link
MemberAuthor

I have sorted out the reason (but not the cause) of the rotate_image failures, for some reason theset_bad from the test added here is leaking out to other tests.

@QuLogic
Copy link
Member

QuLogic commentedMar 15, 2017
edited
Loading

Maybe it should usedeepcopy instead ofcopy?

@tacaswell
Copy link
MemberAuthor

That would fix it, but we should also fixColorMap so that copy works as expected, see#8299

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@phobsonphobsonphobson left review comments

@dstansbydstansbydstansby approved these changes

@dopplershiftdopplershiftdopplershift approved these changes

Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v2.0.1
Development

Successfully merging this pull request may close these issues.

6 participants
@tacaswell@QuLogic@dopplershift@phobson@dstansby@NelleV

[8]ページ先頭

©2009-2025 Movatter.jp