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

Minor cleanup and add test for offsetbox#24486

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 1 commit intomatplotlib:mainfromoscargus:offsetboxtests
Feb 2, 2023

Conversation

oscargus
Copy link
Member

PR Summary

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

@@ -114,7 +114,7 @@ def _get_packed_offsets(widths, total, sep, mode="fixed"):
offsets = offsets_[:-1]
return total, offsets

elif mode == "equal":
else: # "equal"
Copy link
Member

Choose a reason for hiding this comment

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

I don't know whether this is better. On the one hand, you don't need it. On the other hand, keeping the symmetry and stating the value explicitly (not only as a comment also has some appeal.

Execution-wise it makes no difference. There is however a difference in case the if-else-chain gets out of sync with thecheck_in_list above. When usingelse other values will be treated like "equal". When usingelif mode other values don't get that execution block and the function will continue. Both leads to an incorrect result, but theelif solution will most likely blow up in one way or the other, which is preferable IMHO.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The reason was to be able to get full test coverage. Now I tried another pattern that I've seen used: placing the check_in_list in a final else-clause, so more used to raise an error than to check the arguments beforehand.

I guess that in general there should be a preferred way, but it seems like there isn't.

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I don't worry too much about full test coverage. It's onerous in some cases, and full test coverage does not mean your code is working correctly. Test coverage is only a weak indicator and we should be pragmatic about it.

I agree there should be a preferred way. Maybe we should briefly discuss this in a dev call. Unfortunately, there is no really good solution. You always have the duplication between the if/else cases and the values in check_in_list with the danger of being out of sync. For readability, I prefercheck_in_list at the top, because that limits the scope what can happen in the code afterwards and thus reduces mental load.

@oscargusoscargus marked this pull request as draftNovember 18, 2022 10:21
@oscargusoscargus marked this pull request as ready for reviewDecember 8, 2022 09:05
@QuLogicQuLogic added the status: needs comment/discussionneeds consensus on next step labelDec 14, 2022
@oscargusoscargusforce-pushed theoffsetboxtests branch 2 times, most recently from7f28431 to79247c1CompareDecember 28, 2022 10:34
@oscargus
Copy link
MemberAuthor

I removed the discussion point since that was a simple cleanup and will open an issue instead. This is now just tests.

Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

Seems like a useful set of tests to add. Thanks!

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

@jklymakjklymakjklymak approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.8.0
Development

Successfully merging this pull request may close these issues.

4 participants
@oscargus@jklymak@timhoffm@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp