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

Appearance settings

Added test_hist in test_datetime.py #27028

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 12, 2023
Merged
Changes from all 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
47 changes: 44 additions & 3 deletions 47 lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,52 @@ def test_hexbin(self):
fig, ax = plt.subplots()
ax.hexbin(...)

@pytest.mark.xfail(reason="Test for hist not written yet")
@mpl.style.context("default")
def test_hist(self):
fig, ax = plt.subplots()
ax.hist(...)
mpl.rcParams["date.converter"] = 'concise'

start_date = datetime.datetime(2023, 10, 1)
time_delta = datetime.timedelta(days=1)

values1 = np.random.randint(1, 10, 30)
values2 = np.random.randint(1, 10, 30)
values3 = np.random.randint(1, 10, 30)

bin_edges = [start_date + i * time_delta for i in range(31)]

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True)
ax1.hist(
[start_date + i * time_delta for i in range(30)],
bins=10,
weights=values1
)
ax2.hist(
[start_date + i * time_delta for i in range(30)],
bins=10,
weights=values2
)
ax3.hist(
[start_date + i * time_delta for i in range(30)],
bins=10,
weights=values3
)

fig, (ax4, ax5, ax6) = plt.subplots(3, 1, constrained_layout=True)
ax4.hist(
[start_date + i * time_delta for i in range(30)],
bins=bin_edges,
weights=values1
)
ax5.hist(
[start_date + i * time_delta for i in range(30)],
bins=bin_edges,
weights=values2
)
ax6.hist(
[start_date + i * time_delta for i in range(30)],
bins=bin_edges,
weights=values3
)

@pytest.mark.xfail(reason="Test for hist2d not written yet")
@mpl.style.context("default")
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.