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

Offsetbox default arguments#24652

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 15 commits intomatplotlib:mainfromKrutarth-P:offsetboxArguments
Dec 14, 2022

Conversation

Ali-Msk
Copy link
Contributor

@Ali-MskAli-Msk commentedDec 7, 2022
edited by oscargus
Loading

PR Summary

Closes#24623

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (andpytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a.. versionadded:: directive in the docstring and documented indoc/users/next_whats_new/
  • API changes are marked with a.. versionchanged:: directive in the docstring and documented indoc/api/next_api_changes/
  • Release notes conform with instructions innext_whats_new/README.rst ornext_api_changes/README.rst

Copy link

@github-actionsgithub-actionsbot 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 uson gitter for real-time discussion.

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

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

@jklymak
Copy link
Member

Thanks for the PR! For ease of review, suggest a description of the change and moving the issues from title to the description.

Krutarth-P reacted with thumbs up emoji

@@ -369,12 +369,12 @@ def draw(self, renderer):


class PackerBase(OffsetBox):
def __init__(self, pad=None, sep=None, width=None, height=None,
def __init__(self, pad=0., sep=None, width=None, height=None,
Copy link
Member

@oscargusoscargusDec 7, 2022
edited
Loading

Choose a reason for hiding this comment

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

I think the same problem holds for sep as well?

Edited: width and height are calculated, but sep must be set.

align="baseline", mode="fixed", children=None):
"""
Parameters
----------
pad : float,optional
pad : float,required
Copy link
Member

Choose a reason for hiding this comment

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

It is still optional, just that it has a correct default now.

@oscargus
Copy link
Member

Can you please how the outcome of the example code in#24620? Ideally as an image test, but if nothing else just paste the result here.

try:
pb = PaddedBox(at, patch_attrs={'facecolor': 'r'}, draw_frame=True)
except:
raise Exception("incorrect default value")
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to do this in a test. The test will fail if there is an exception anyway, so skip the try-except.

You can add a comment like

# smoke test for correct default value though

@Skhaki18
Copy link
Contributor

Plot

This was our result when running the code from24620 with the default padding of 0. Additionally, we can see the result for padding=5 below:

Plot2

@jklymakjklymak changed the title[#24623][#24620] Offsetbox arguments and incorrect locationOffsetbox arguments and incorrect locationDec 7, 2022
@jklymakjklymak added status: needs tests status: needs clarificationIssues that need more information to resolve. labelsDec 7, 2022
@jklymak
Copy link
Member

I'm moving this to draft. Feel free to move back when ready for review.

@jklymakjklymak marked this pull request as draftDecember 7, 2022 16:46
@oscargus
Copy link
Member

There is an update in#24620 which shows that PaddedBox is indeed working. And it looks like the proposed solution is not fully handling it.

Hence, my suggestion is to drop the location changes and just go with the default argument ones.

@Krutarth-P
Copy link
Contributor

There is an update in#24620 which shows that PaddedBox is indeed working. And it looks like the proposed solution is not fully handling it.

Hence, my suggestion is to drop the location changes and just go with the default argument ones.

We have made the changes according to your request to use the default values. Would you know how to resolve the CircleCi errors?

@oscargus
Copy link
Member

The Circle CI issue is a bit weird. It it not related to the contents of your PR anyway. I think I've seen some issue recently where a particular user couldn't run the tests and the best guess was that the GitHub user name was changed. Would that possibly be the case here? Has anyone of you changed GitHub user name after you created your account?

@Krutarth-P
Copy link
Contributor

The Circle CI issue is a bit weird. It it not related to the contents of your PR anyway. I think I've seen some issue recently where a particular user couldn't run the tests and the best guess was that the GitHub user name was changed. Would that possibly be the case here? Has anyone of you changed GitHub user name after you created your account?

change of name doesn't seem to be the case here. any other possible reasons for the error?

@Krutarth-P
Copy link
Contributor

@oscargus@jklymak the builds are successful. We are ready for a review

@rcomerrcomer marked this pull request as ready for reviewDecember 11, 2022 08:18
Copy link
Member

@oscargusoscargus left a comment

Choose a reason for hiding this comment

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

Just some minor comments. The testing is good to get correct though.

One may consider changingoptional todefault: 0.0 in the doc strings. (Or addDefault: 0.0. to the description, but I think the first is preferred.)

# smoke test for correct default value though
fig, ax = plt.subplots()
at = AnchoredText("foo", 'upper left')
pb = PaddedBox(at, patch_attrs={'facecolor': 'r'}, draw_frame=True)
Copy link
Member

Choose a reason for hiding this comment

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

This test passes on main as well. (As the fact that pad is None is not a problem until later on.)

You need to do:

ax.add_artist(pb)fig.draw_without_rendering()

If you can also add a similar thing for one of the packers that would be great! Can go in the same test/figure. There is a previous test for the packers that you can just copy the relevant code from, but leave the pad and sep arguments out.

Krutarth-P reacted with thumbs up emoji
Krutarth-Pand others added5 commitsDecember 12, 2022 14:33
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
@Skhaki18
Copy link
Contributor

Skhaki18 commentedDec 14, 2022
edited
Loading

@oscargus and@rcomer , We have addressed the requested comments and added the necessary tests. We are able to build successfully and are ready for the next step in merging.

Copy link
Member

@oscargusoscargus left a comment
edited
Loading

Choose a reason for hiding this comment

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

Thanks!

I guess this is good to go now. The addition of HPacker/VPacker tests is maybe not so clear, but it will work and test what is expected.

An better option is to simply remove the two previous lines where pad and sep are set as they are now redundant.

Whoever merges this: please squash the commits. (I take it that you are using the web-based interface for editing the files?)

@oscargusoscargus removed status: needs clarificationIssues that need more information to resolve. status: needs tests labelsDec 14, 2022
@oscargusoscargus changed the titleOffsetbox arguments and incorrect locationOffsetbox default argumentsDec 14, 2022
@timhoffm
Copy link
Member

An better option is to simply remove the two previous lines where pad and sep are set as they are now redundant.
r editing the files?)

I took the liberty to commit this change.

@timhoffmtimhoffm added this to thev3.7.0 milestoneDec 14, 2022
@timhoffmtimhoffm merged commit58de4e2 intomatplotlib:mainDec 14, 2022
@timhoffm
Copy link
Member

Thanks@Ali-Msk and congratulations on your first contribution to Matplotlib!

We hope to see you again.

melissawm pushed a commit to melissawm/matplotlib that referenced this pull requestDec 19, 2022
Closesmatplotlib#24652Co-authored-by: Skhaki18 <samir.khaki@mail.utoronto.ca>Co-authored-by: Krutarth Patel <kv.patel@mail.utoronto.ca>Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@rcomerrcomerrcomer left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@timhoffmtimhoffmtimhoffm approved these changes

@oscargusoscargusoscargus approved these changes

Assignees
No one assigned
Projects
Milestone
v3.7.0
Development

Successfully merging this pull request may close these issues.

[Bug]:offsetbox classes have optional arguments that are really not optional
7 participants
@Ali-Msk@jklymak@oscargus@Skhaki18@Krutarth-P@timhoffm@rcomer

[8]ページ先頭

©2009-2025 Movatter.jp