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

Fixed incorrect colour in ErrorBar when Nan value is presented#16724

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
timhoffm merged 5 commits intomatplotlib:masterfromCSCD01-team20:Fix-13799
Mar 22, 2020

Conversation

henryhu123
Copy link
Contributor

PR Summary

Fixed incorrect colour in ErrorBar when Nan value is presented
See#13799
Co-author : Dennis TismenkoDennis.Tismenko@mail.utoronto.ca

After analyzing the codebase, the inconsistency issue was traced to the difference between the handling of NaN values in Axes.scatter versus Axes.hlines/Axes.vlines. In the latter case, NaN values were being deleted from their respective np.array, whereas in the former case, NaN values were handled by using a np.ma.array (masked array), where the NaN values were simply masked.

Removed cbook.delete_masked_points() when passing X and Y to Errorbar.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswelltacaswell added this to thev3.3.0 milestoneMar 11, 2020
@tacaswell
Copy link
Member

Overall this seems like the correct fix 👍

I am a bit concerned about the images that changed but look identical. Are there very small changes in them?

For the tests would it be possible to usecheck_figures_equal instead of adding new images?

Seehttps://matplotlib.org/api/testing_api.html#matplotlib.testing.decorators.check_figures_equal andhttps://matplotlib.org/devel/testing.html#writing-an-image-comparison-test

@tacaswell
Copy link
Member

Could you please also simplify / sqaush the git history?

@tacaswelltacaswell self-assigned thisMar 11, 2020
@henryhu123
Copy link
ContributorAuthor

Overall this seems like the correct fix 👍

I am a bit concerned about the images that changed but look identical. Are there very small changes in them?

For the tests would it be possible to usecheck_figures_equal instead of adding new images?

Seehttps://matplotlib.org/api/testing_api.html#matplotlib.testing.decorators.check_figures_equal andhttps://matplotlib.org/devel/testing.html#writing-an-image-comparison-test

@henryhu123
Copy link
ContributorAuthor

Overall this seems like the correct fix 👍

I am a bit concerned about the images that changed but look identical. Are there very small changes in them?

For the tests would it be possible to usecheck_figures_equal instead of adding new images?

Seehttps://matplotlib.org/api/testing_api.html#matplotlib.testing.decorators.check_figures_equal andhttps://matplotlib.org/devel/testing.html#writing-an-image-comparison-test

Sorry accidentally closed the PR. Actually I didn't modify the images for hlines_basics, hlines_with_nan, hlines_masked, vlines_basics, vlines_with_nan, vlines_masked. Not sure why GitHub shows it is modified, I will look into at this issue. Thank you for your feedback.

@henryhu123
Copy link
ContributorAuthor

Overall this seems like the correct fix 👍
I am a bit concerned about the images that changed but look identical. Are there very small changes in them?
For the tests would it be possible to usecheck_figures_equal instead of adding new images?
Seehttps://matplotlib.org/api/testing_api.html#matplotlib.testing.decorators.check_figures_equal andhttps://matplotlib.org/devel/testing.html#writing-an-image-comparison-test

Sorry accidentally closed the PR. Actually I didn't modify the images for hlines_basics, hlines_with_nan, hlines_masked, vlines_basics, vlines_with_nan, vlines_masked. Not sure why GitHub shows it is modified, I will look into at this issue. Thank you for your feedback.

Re-uploaded the original test images, test images are not changed now. Can we do the squash merge?

@DennisTismenko
Copy link
Contributor

@henryhu123 I squashed the git history, so I don't think there's a need for a squash merge.

Included changes to the tests to usecheck_figures_equal instead of image comparison, thank you for the good suggestion.

Copy link
Member

@QuLogicQuLogic left a comment

Choose a reason for hiding this comment

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

Please give your commitsmeaningful message;#13799 is meaningless in agit log.

Combine array masks rather than deleting masked points to maintainconsistency across the project.Add appropriate test cases for validating color correctness for hlinesand vlines.Fixes issuematplotlib#13799.
@DennisTismenko
Copy link
Contributor

@QuLogic Thank you for your feedback, I implemented both the changes to the commit message and the code wrapping. We also implemented your suggestions for the tests and fixed the incorrect method calls.

@QuLogic
Copy link
Member

I think you might have misunderstood what parametrization is for, and usingcycler, while cool, is a bit overkill here. Almost all of your cyclers are 1 element except one that is 2, so their product is 2 long. It seems less work just to write out those 2 differing things.

The point of parametrizing is to remove duplication. Most of that code should still be in the test, and only the changing things need to be parametrized. Certainly the expected data is fixed and there's no need to obfuscate it by putting it in a parameter. I was thinking more that you should parametrize overvlines/hlines originally, though parametrizing over the two test cases is also a good idea.

@henryhu123
Copy link
ContributorAuthor

I think you might have misunderstood what parametrization is for, and usingcycler, while cool, is a bit overkill here. Almost all of your cyclers are 1 element except one that is 2, so their product is 2 long. It seems less work just to write out those 2 differing things.

The point of parametrizing is to remove duplication. Most of that code should still be in the test, and only the changing things need to be parametrized. Certainly the expected data is fixed and there's no need to obfuscate it by putting it in a parameter. I was thinking more that you should parametrize overvlines/hlines originally, though parametrizing over the two test cases is also a good idea.

I have removedcycler and moved expected data to test cases. Not sure if I understand your last sentence correctly, I removed duplicated code as much as possible, and created one parametrizing generator function for both hlines/vlines test cases.


@pytest.mark.parametrize('kwargs', generate_lines_with_colors_inputs())
@check_figures_equal(extensions=["png"])
def test_vlines_with_colors(fig_test, fig_ref, kwargs):
Copy link
Member

@timhoffmtimhoffmMar 19, 2020
edited
Loading

Choose a reason for hiding this comment

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

You can greatily simplify the tests:

  • The only variable part is the data. All other parameters are identical. You can just hard-code them. No need to build dicts and pass them askwargs.
  • ymin/ymax can be scalars.
  • You can testhlines andvlines within one figure:
    image
  • Optionally / alternatively, you can make 2 or 4 subplots and draw the different cases into different axes on the same figure.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

  • Removed passing kwargs, hard-code the identical values.
  • ymin/ymax are scalars now
  • hlines and vlines is in one figure with 2 subplots now.

ymin = np.ma.resize(ymin, x.shape)
ymax = np.ma.resize(ymax, x.shape)

masked_verts = [np.ma.array([xymin, xymax])
Copy link
Member

Choose a reason for hiding this comment

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

Simpler and faster:

        masked_verts = np.ma.empty((len(x), 2, 2))        masked_verts[:, 0, 0] = x        masked_verts[:, 1, 0] = x        masked_verts[:, 0, 1] = ymin        masked_verts[:, 1, 1] = ymax

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that is definitely cleaner than what I had before, thank you for the suggestion! Pushed.

@henryhu123
Copy link
ContributorAuthor

@timhoffm Hi, do you have any idea why Travis CI MacOs build test failed, I have looked through error information and have no idea how to fix it.

@QuLogic
Copy link
Member

This is a known issue#16849.

@DennisTismenko
Copy link
Contributor

Pushed the suggested order changes to the creation ofmasked_verts.

@timhoffmtimhoffm merged commit382be60 intomatplotlib:masterMar 22, 2020
@timhoffm
Copy link
Member

Thanks to all who have contributed to this!

tacaswell reacted with hooray emoji

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

@DennisTismenkoDennisTismenkoDennisTismenko left review comments

@QuLogicQuLogicQuLogic approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees

@tacaswelltacaswell

Labels
None yet
Projects
None yet
Milestone
v3.3.0
Development

Successfully merging this pull request may close these issues.

5 participants
@henryhu123@tacaswell@DennisTismenko@QuLogic@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp