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

Commit1f7151e

Browse files
authored
Merge pull request#23047 from oscargus/histfix
2 parents2304ae7 +3473eca commit1f7151e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6651,6 +6651,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
66516651
m,bins=np.histogram(x[i],bins,weights=w[i],**hist_kwargs)
66526652
tops.append(m)
66536653
tops=np.array(tops,float)# causes problems later if it's an int
6654+
bins=np.array(bins,float)# causes problems if float16
66546655
ifstacked:
66556656
tops=tops.cumsum(axis=0)
66566657
# If a stacked density plot, normalize so the area of all the

‎lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,21 @@ def test_hist_bar_empty():
18631863
ax.hist([],histtype='bar')
18641864

18651865

1866+
deftest_hist_float16():
1867+
np.random.seed(19680801)
1868+
values=np.clip(
1869+
np.random.normal(0.5,0.3,size=1000),0,1).astype(np.float16)
1870+
h=plt.hist(values,bins=3,alpha=0.5)
1871+
bc=h[2]
1872+
# Check that there are no overlapping rectangles
1873+
forrinrange(1,len(bc)):
1874+
rleft=bc[r-1].get_corners()
1875+
rright=bc[r].get_corners()
1876+
# right hand position of left rectangle <=
1877+
# left hand position of right rectangle
1878+
assertrleft[1][0]<=rright[0][0]
1879+
1880+
18661881
@image_comparison(['hist_step_empty.png'],remove_text=True)
18671882
deftest_hist_step_empty():
18681883
# From #3886: creating hist from empty dataset raises ValueError

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp