Skip to content

MNT: make Axes.cla an alias for Axes.clear in all cases #22802

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 1 commit into from
Apr 17, 2022

Conversation

lijake8
Copy link
Contributor

@lijake8 lijake8 commented Apr 8, 2022

PR Summary

We (myself and @neil-gurnani) consolidated all implementations of cla/clear under a clear method (the clear functionality is implemented in clear, and cla calls clear for the sake of minimizing code duplication and improving maintainability). We added 2 tests ensuring subclasses do not override cla. Existing tests for cla were left as-is; since cla calls clear, coverage is not compromised.

Every subclass has both cla and clear, since it was mentioned in #22738 that cla is still too widely used to be fully deprecated as of now. We added appropriate docstrings/comments for all cla/clear methods.

We left all original '_api.deprecated' decorators as-is but did not add any new decorators (please let us know if this is needed).

Finally, please let us know if there's any issue with this PR we should address. This was our first PR and we really enjoyed working on it.

Thanks

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.

@oscargus oscargus added topic: axes status: needs workflow approval For PRs from new contributors, from which GitHub blocks workflows by default. labels Apr 8, 2022
@timhoffm timhoffm removed the status: needs workflow approval For PRs from new contributors, from which GitHub blocks workflows by default. label Apr 8, 2022
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Looks like a great start! I think there were a few places that you added in a definition of cla() into a subclass when it could be inherited from the superclass, so I'd suggest looking at what each of the classes is inheriting from and making sure that there is a cla() in the parent that can get used. Let me know if that doesn't make sense or if I'm mistaken too!

Also, if you want to add your friend as a contributor on the commit, you can use the "co-authored-by" feature in the commit message: https://docs.github.com/en/github-ae@latest/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors

@lijake8 lijake8 force-pushed the mnt-make-cla-an-alias-for-clear branch from bccc557 to 20f8c8b Compare April 9, 2022 23:37
@lijake8
Copy link
Contributor Author

lijake8 commented Apr 9, 2022

Looks like a great start! I think there were a few places that you added in a definition of cla() into a subclass when it could be inherited from the superclass, so I'd suggest looking at what each of the classes is inheriting from and making sure that there is a cla() in the parent that can get used. Let me know if that doesn't make sense or if I'm mistaken too!

@greglucas Thanks for the feedback and suggestions! I just amended the PR. Summary:

  • The cla() methods are now removed from all axes subclasses.
  • The test case is also updated and (locally) is verified to be passing.
  • Relevant deprecations have been removed and logged in the doc/api/next_api_changes/removals folder.

Please let me know if there's anything else I should do!

@lijake8 lijake8 force-pushed the mnt-make-cla-an-alias-for-clear branch from 71ddfe1 to c8dd978 Compare April 11, 2022 03:49
@lijake8
Copy link
Contributor Author

lijake8 commented Apr 11, 2022

Just pushed our updates. Unfortunately, we accidentally fetched from upstream before pushing and as a result there are some changes (particularly in pyplot) that are from upstream (the root matplotlib repo). Hopefully this is ok - if not, is there any way around this?

@neil-gurnani
Copy link

neil-gurnani commented Apr 11, 2022

@greglucas Thanks for the feedback and suggestions! When trying to merge my changes to the current commit, I kept running into Failed to Push Refs due to stale info errors as shown here. Then I tried to "fetch the updates from upstream and rebase first" as outlined in this source, which caused the merge from main commit you saw.

Anyways, my partner (@lijake8) was able to amend our changes for this PR.

Summary:

  • Reverted pyplot.py file to the pre-PR version with no addition of a clear() function

  • Removed the test_cla_not_redefined() function from the test_figure.py file.

  • Removed the def cla(self) for ParasiteAxes , HostAxes, and FloatingAxes as these three inherit from the Axes parent class using theClassFactory method.

Please let me know if there's anything else we should revise or do!

@lijake8 lijake8 force-pushed the mnt-make-cla-an-alias-for-clear branch 7 times, most recently from 522b9a7 to f2418bf Compare April 12, 2022 02:12
@lijake8
Copy link
Contributor Author

lijake8 commented Apr 12, 2022

FInally fixed the commits issue with latest updates in accordance with notes above

Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just two very minor comments here. Then we just need to wait for a second reviewer before merging.

@@ -796,7 +796,6 @@ def test_clf_not_refedined():
# check that subclasses do not get redefined in our Figure subclasses
assert 'clf' not in klass.__dict__


Copy link
Contributor

Choose a reason for hiding this comment

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

Hm... Is flake8 not getting run on tests? I'm pretty sure this line should be there. This file should also be left alone if you aren't touching it anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@lijake8 lijake8 force-pushed the mnt-make-cla-an-alias-for-clear branch 3 times, most recently from deafadc to bcbe1ca Compare April 12, 2022 14:18
@lijake8 lijake8 changed the title #22738 [MNT]: make Axes.cla an alias for Axes.clear in all cases MNT: make Axes.cla an alias for Axes.clear in all cases Apr 15, 2022
@lijake8 lijake8 force-pushed the mnt-make-cla-an-alias-for-clear branch from bcbe1ca to ec95f99 Compare April 17, 2022 01:34
@lijake8
Copy link
Contributor Author

lijake8 commented Apr 17, 2022

@timhoffm @oscargus Do either of you mind reviewing this PR? Thanks!

@timhoffm timhoffm merged commit 2c5fc8e into matplotlib:main Apr 17, 2022
@timhoffm
Copy link
Member

Thanks @lijake8 and congratulations on your first contribution to Matplotlib! We hope to see you again.

@neil-gurnani
Copy link

neil-gurnani commented Apr 17, 2022

@timhoffm My partner @lijake8 and I both worked on contributing to this issue together.

We also added my name as a co-author to the commit message of our PR as instructed by @greglucas above:
"Also, if you want to add your friend as a contributor on the commit, you can use the "co-authored-by" feature in the commit message: https://docs.github.com/en/github-ae@latest/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors"

Link to Co-Author Confirmation Screenshot: https://drive.google.com/file/d/14Jq8-fY_ZnIRJhUmypprvf4rG7A3Y6xk/view?usp=sharing

Can you confirm that both myself @neil-gurnani (Neil Gurnani) and my partner (@lijake8) will be credited for this contribution?

Thank you for your guidance with this and your approval of our Pull Request!

@timhoffm
Copy link
Member

timhoffm commented Apr 18, 2022

Can you confirm that both myself @neil-gurnani (Neil Gurnani) and my partner (@lijake8) will be credited for this contribution?

You’ve not followed the format that GitHub defines for co-author attribution. So on the technical side only @lijake8’s account is linked to the PR. OTOH @neil-gurnani your name is in the commit message, which states that you have contributed.

@tacaswell
Copy link
Member

As Tim said, it looks like the commit message did not trigger the co-author logic in GH. I suspect the issue is that GH is looking for the tags at the end, but you put it in the first line of the commit message (that normally says what it is you did).

On one hand I am sympathetic to wanting to get this fixed and get your name listed on GH as a contributor. On the other hand I do not think we want to do a force-push to main to re-write history to fix the commit message (we have force pushed to main in the past but it is my judgement that this does not cross the threshold to do that) and I do not think that adding an empty commit with your name on it is a good option either (it makes it really odd if anyone looks it up later and I think is a bad precedent to set).

Given that the concept of co-authoring is a GH concept (rather than a pure git concept), it may be worth reaching out to github support about this. At a minimum they can add a warning to their docs about where the line is searched for.

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

Successfully merging this pull request may close these issues.

7 participants