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

Add some tests for minspan{x,y} in RectangleSelector#22154

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
QuLogic merged 1 commit intomatplotlib:mainfromdstansby:minspan-tests
Jan 18, 2022

Conversation

dstansby
Copy link
Member

PR Summary

There aren't currently any tests for theminspan{x,y} arguments, so add some. There isn't any public API for checking if a given selector is currently 'active', so I had to use the privatetool._selection_completed flag for that.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

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

@dstansbydstansby added this to thev3.6.0 milestoneJan 8, 2022
Copy link
Member

@ericpreericpre left a comment

Choose a reason for hiding this comment

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

This is nice, I have left one suggestion for improvement!

@pytest.mark.parametrize('minspany, y1', [[0, 10], [1, 10.5], [1, 11]])
def test_rectangle_minspan(spancoords, minspanx, x1, minspany, y1):
ax = get_ax()
ax._n_onselect = 0
Copy link
Member

Choose a reason for hiding this comment

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

AFAICS this dynamically adds an attribute. If so, this needs explanation:

Suggested change
ax._n_onselect=0
# add an attribute to track the number of onselect calls
ax._n_onselect=0

OTOH you are only working with a single axis. Couldn't you just use a local variable?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I tried a local variable and it gives

defonselect(epress,erelease):>n_onselect+=1EUnboundLocalError:localvariable'n_onselect'referencedbeforeassignment

I've added a comment though

Copy link
Member

Choose a reason for hiding this comment

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

That would probably need anonlocal statement. But I can live with a comment as well.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like a use case forMock? Thenassert_not_called,assert_called_once_with, etc.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm happy to look into mocking, but would advocate for this PR to go in first so#21945 can be tested with these tests, and because the current code is how other widget tests do similar checks.

@QuLogicQuLogic merged commitd7e3383 intomatplotlib:mainJan 18, 2022
@dstansbydstansby deleted the minspan-tests branchJanuary 18, 2022 11:22
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@ericpreericpreericpre approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

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

Successfully merging this pull request may close these issues.

4 participants
@dstansby@QuLogic@timhoffm@ericpre

[8]ページ先頭

©2009-2025 Movatter.jp