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

Commit7c02e85

Browse files
Added test_hist in test_datetime.py (#27028)
* Added test_hist* reset* remove comment* Added test_hist* added test_hist.py to test_datetime.py* comply with PEP8* datetime as bins* datetime as bins
1 parentc06a97e commit7c02e85

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

‎lib/matplotlib/tests/test_datetime.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,52 @@ def test_hexbin(self):
170170
fig,ax=plt.subplots()
171171
ax.hexbin(...)
172172

173-
@pytest.mark.xfail(reason="Test for hist not written yet")
174173
@mpl.style.context("default")
175174
deftest_hist(self):
176-
fig,ax=plt.subplots()
177-
ax.hist(...)
175+
mpl.rcParams["date.converter"]='concise'
176+
177+
start_date=datetime.datetime(2023,10,1)
178+
time_delta=datetime.timedelta(days=1)
179+
180+
values1=np.random.randint(1,10,30)
181+
values2=np.random.randint(1,10,30)
182+
values3=np.random.randint(1,10,30)
183+
184+
bin_edges= [start_date+i*time_deltaforiinrange(31)]
185+
186+
fig, (ax1,ax2,ax3)=plt.subplots(3,1,constrained_layout=True)
187+
ax1.hist(
188+
[start_date+i*time_deltaforiinrange(30)],
189+
bins=10,
190+
weights=values1
191+
)
192+
ax2.hist(
193+
[start_date+i*time_deltaforiinrange(30)],
194+
bins=10,
195+
weights=values2
196+
)
197+
ax3.hist(
198+
[start_date+i*time_deltaforiinrange(30)],
199+
bins=10,
200+
weights=values3
201+
)
202+
203+
fig, (ax4,ax5,ax6)=plt.subplots(3,1,constrained_layout=True)
204+
ax4.hist(
205+
[start_date+i*time_deltaforiinrange(30)],
206+
bins=bin_edges,
207+
weights=values1
208+
)
209+
ax5.hist(
210+
[start_date+i*time_deltaforiinrange(30)],
211+
bins=bin_edges,
212+
weights=values2
213+
)
214+
ax6.hist(
215+
[start_date+i*time_deltaforiinrange(30)],
216+
bins=bin_edges,
217+
weights=values3
218+
)
178219

179220
@pytest.mark.xfail(reason="Test for hist2d not written yet")
180221
@mpl.style.context("default")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp