Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix array-like linewidth for 3d scatter #23434

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

Merged
merged 4 commits into from
Aug 3, 2022

Conversation

krassowski
Copy link
Contributor

PR Summary

Fixes #23433 by casting self._linewidths3d to np.array at the latest stage possible and adds a test to ensure it works.

The casting step could alternatively be moved to happen earlier in the code logic in set_linewidth and in set_3d_properties, but I went for the simplest solution possible. Let me know if you want to change that (in that case, is self._linewidth3d = lw a typo? should it be _linewidths3d?)

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@QuLogic
Copy link
Member

QuLogic commented Jul 17, 2022

I think it'd be better to not do this so late, since this is in the draw call. Then the array can be done once instead of every refresh, which could be a bit slow.

@oscargus
Copy link
Member

I think this should be changed as well:

def set_linewidth(self, lw):
super().set_linewidth(lw)
if not self._in_draw:
self._linewidth3d = lw

Both changing the name from _linewidth3d to _linewidths3d and converting into an np-array.

@oscargus
Copy link
Member

oscargus commented Jul 20, 2022

Maybe one can also add a check_figures_equal test that uses the set_linewidth method for one of the figures and the keyword argument for the other?

(See the test just below the one you added to see how they work.)

@oscargus oscargus added this to the v3.6.0 milestone Jul 20, 2022
@krassowski
Copy link
Contributor Author

krassowski commented Jul 22, 2022

Maybe one can also add a check_figures_equal test that uses the set_linewidth method for one of the figures and the keyword argument for the other?

(See the test just below the one you added to see how they work.)

To clarify, since set_linewidths is already there in the test case that you are pointing to (and since self._linewidths was already getting properly set in the super() call it worked ok for scalars as tested), would you like me to add another test like that, but testing that array-likes can be set via keyword argument and setter?

Edit: added, can remove if not needed.

@oscargus
Copy link
Member

oscargus commented Jul 22, 2022

Considering the spelling error, I do not think that it was actually properly tested, so ideally there should be a test that does set_linewidth and relies on that the spelling is correct.

(The spelling error was introduced in #19812 btw.)

@krassowski
Copy link
Contributor Author

The test which I added in 2bdbdca should cover that. The documentation build seems to be failing, is there anything I should do, or is it intermittent CI issue?

@scottshambaugh
Copy link
Contributor

scottshambaugh commented Jul 25, 2022

@krassowski looking at the docs build logs, I think this was just an intermittent CI issue. I don't think there's a way to re-trigger the tests through the github gui, but if you do a git commit --amend followed by a git push -f I believe that should change the timestamp on your last commit and cause the CI tests to rerun.

@krassowski
Copy link
Contributor Author

Thanks, all checks have passed now πŸŽ‰

@krassowski
Copy link
Contributor Author

A gentle ping on this PR :)

@tacaswell tacaswell merged commit 16ad86e into matplotlib:main Aug 3, 2022
@tacaswell
Copy link
Member

Congratulations on your first merged Matplotlib PR @krassowski πŸŽ‰ Hopefully we will hear from you again!

Also thank you for the gentle ping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[Bug]: array-like linewidth raises an error for scatter3D
5 participants