Skip to content

Don't make VBoxDivider inherit from HBoxDivider. #20069

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 2 commits into from
Apr 27, 2021
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Apr 25, 2021

They share some common calculation helpers, but a VBoxDivider is not a
specialization of an HBoxDivider, so just move the helpers out to free
functions (they're staticmethods or nearly so anyways).

Also rename "equivalent" to "equal" and "appended" to "summed", which I
think actually express the constraints better, and are shorter too.

Also document their usage, and PEP8-ify a couple of variables.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@jklymak
Copy link
Member

jklymak commented Apr 25, 2021

While you are fixing all this I don't think any of it works properly with subfigures because it depends on figsize.

@anntzer
Copy link
Contributor Author

anntzer commented Apr 25, 2021

Looks like this may be simple enough to fix by replacing get_size_inches() by self._fig.bbox.{width,height} / self._fig.dpi. Open a separate issue to track this and I'll put in something on top of this PR and #20072? Edit: well, it's #20073 :)

@anntzer anntzer mentioned this pull request Apr 25, 2021
7 tasks
@timhoffm
Copy link
Member

I'm not particularly happy with the style of this. These methods are quite obscure. As private static methods, at least their scope was clear. I find the prefix _hvboxdiv also more confusing than helpful: merging both names to hv and abbreviating div makes this too different from HBoxDivider to infer a connection.

Suggested minimal improvement: Remove the _hvboxdiv prefix and add a comment "Helper function used in HBoxDivider/VBoxDivider".

For future PRs: Please split moving code and renaming variables into separate commits. This is really hard to follow.

They share some common calculation helpers, but a VBoxDivider is not a
specialization of an HBoxDivider, so just move the helpers out to free
functions (they're staticmethods or nearly so anyways).
@anntzer
Copy link
Contributor Author

anntzer commented Apr 26, 2021

Added some more comments, and split the variable renaming into a second commit. The first one is solely about moving the staticmethods out, now.

The alternative would be to have a private common base class to host the staticmethods, but private base classes come with their own problems...

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Much simpler to review. Thanks for cleaning up. 😄

The alternative would be to have a private common base class to host the staticmethods, but private base classes come with their own problems...

I intentionally did not suggest that 😜

... in internal APIs to always have x/width first, y/height second.
@anntzer
Copy link
Contributor Author

anntzer commented Apr 26, 2021

Actually, I further amended the second commit to always put the width first and height second in the internal APIs (instead of having x/y but then height/width).

@jklymak jklymak merged commit 37fcc3f into matplotlib:master Apr 27, 2021
@anntzer anntzer deleted the vhb branch April 27, 2021 14:31
@QuLogic QuLogic added this to the v3.5.0 milestone Jun 29, 2021
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.

4 participants