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 test_quiver in test_datetime.py#27407

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
rawwash wants to merge3 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromrawwash:quiver
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletionslib/matplotlib/tests/test_datetime.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -446,11 +446,20 @@ def test_plot_date(self):
ax2.plot_date(x_dates, y_ranges)
ax3.plot_date(x_ranges, y_dates)

@pytest.mark.xfail(reason="Test for quiver not written yet")
@mpl.style.context("default")
def test_quiver(self):
fig, ax = plt.subplots()
ax.quiver(...)
dates = [datetime.datetime(2023, 1, 1) + datetime.timedelta(days=i)
for i in range(5)]
x = dates
y = np.zeros_like(x, dtype=float)
u = np.sin(np.arange(len(x)))
v = np.cos(np.arange(len(x)))
fig, ax = plt.subplots(figsize=(10, 6))
ax.quiver(x, y, u, v, scale=20)
Copy link
Member

Choose a reason for hiding this comment

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

It seems likey could also be tested? I'm not sure if it also makes sense to tryu andv as well.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Quiver plots typically expect numerical values for u and v (representing vector components), and y is usually a numerical position value. Using datetime objects for these variables would be unconventional and might not work directly with the quiver plot functionality. I think it might be better to maintain the test as is.

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 really follow the assertion thaty is usually a numerical position value. But in any case, these tests are to check whether the code works, not what the "usual" type is. We absolutely want to test things that are unusual.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that y is not actually different from x here and should be tested, additionally Ido think u/v should be tested withangles="xy" and u/v supplied astimedeltas. I think passing u/v as timedeltas shouldnot be included with the (default)angles="uv"

fig.autofmt_xdate()
ax.set_title('Quiver Plot with Datetime Data')
ax.set_xlabel('Date')
ax.set_ylabel('Y-axis')

@pytest.mark.xfail(reason="Test for quiverkey not written yet")
@mpl.style.context("default")
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp