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

[TST] Added test_axlines in test_datetime.py#27326

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

Open
samchan2022 wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromsamchan2022:add-test-axlines

Conversation

samchan2022
Copy link

PR summary

This PR adds a smoke test for Axes.axlines in lib/matplotlib/tests/test_datetime.py. This PR closes one of the items listed in the issue#26864.
Smoke test Plot:
result

PR checklist

@samchan2022samchan2022 changed the titleadd test_axlines[TST] Added test_axlines in test_datetime.pyNov 14, 2023
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 week or so, please leave a new comment below and that should bring it to our attention. 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.

Copy link
Member

@ksundenksunden left a comment

Choose a reason for hiding this comment

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

This has revealed thataxline doesnot support units currently, but I think itcould with relative ease, see my other comment for more details

Since it does not support units currently, we are not actually testing the intended code paths here, so it shouldn't be merged as is.

values = list(range(1, 32))

ax1.plot(dates, values, 'ro')
ax1.axline((date2num(dates[0]), values[0]), (date2num(dates[-1]), values[-1]),
Copy link
Member

Choose a reason for hiding this comment

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

We specifically donot want to usedate2num in these test cases. the fact that it is erroring when handeddatetime objects is precisely the kind of thing we wanted to find out by implementing these tests.

The following patch gets most of the way to fixing it such that you can actually pass datetime objects (though I think it may need some consideration regarding what to do if a non-data transform is provided, or whether "slope" is something that can be meaningfully provided with unitful data):

diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.pyindex 9199f1cafa..524c1ae06a 100644--- a/lib/matplotlib/axes/_axes.py+++ b/lib/matplotlib/axes/_axes.py@@ -919,6 +919,9 @@ class Axes(_AxesBase):                                   self.get_yscale() != 'linear'):             raise TypeError("'slope' cannot be used with non-linear scales")+        xy1 = tuple(self._process_unit_info([("x", xy1[0]), ("y", xy1[1])]))+        if xy2 is not None:+            xy2 = tuple(self._process_unit_info([("x", xy2[0]), ("y", xy2[1])]))         datalim = [xy1] if xy2 is None else [xy1, xy2]         if "transform" in kwargs:             # if a transform is passed (i.e. line points not in data space),

samchan2022 reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

I did the minimal change here to get the point-point version working with the default transform (data space). I do think that the final version would need at least some more.

  • passingkwargs in
  • Maybe pushing the unit transforming down intomlines.AxLine? (trying to trace how baseLine2D does it, if that does it in the class, I'd probably follow suit forAxLine, but not super clear on that, actually...AxLine inherits fromLine2D)
  • some more thought aboutslope may be good... it is already disallowed with non-linear scales, may be best to just disallow it with unitful data or declare it to be in explicitly "unitless data space" (currently it states that it is in 'data coordinates'). I think it may actually work out for at least the case of having the same units on both axes (i.e. the slope is unitless then) or possibly also with full unit libraries, though possibly would require pushing units into theAxLine class for it to work.

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

@ksundenksundenksunden requested changes

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

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Projects
Status: Waiting for author
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@samchan2022@ksunden@melissawm

[8]ページ先頭

©2009-2025 Movatter.jp