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

Commitfc64a19

Browse files
committed
Use check_figures_equal.
1 parent95a4b41 commitfc64a19

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

‎lib/matplotlib/image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ def set_alpha(self, alpha):
293293
self._imcache=None
294294

295295
def_get_scalar_alpha(self):
296-
returnself._alphaifnp.ndim(self._alpha)==0else1.0
296+
return1.0ifself._alphaisNoneornp.ndim(self._alpha)>0 \
297+
elseself._alpha
297298

298299
defchanged(self):
299300
"""

‎lib/matplotlib/tests/test_image.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,3 +1118,22 @@ def test_image_cursor_formatting():
11181118

11191119
data=np.nan
11201120
assertim.format_cursor_data(data)=='[nan]'
1121+
1122+
1123+
@check_figures_equal()
1124+
deftest_image_array_alpha(fig_test,fig_ref):
1125+
'''per-pixel alpha channel test'''
1126+
x=np.linspace(0,1)
1127+
xx,yy=np.meshgrid(x,x)
1128+
1129+
zz=np.exp(-3* ((xx-0.5)**2)+ (yy-0.7**2))
1130+
alpha=zz/zz.max()
1131+
1132+
cmap=plt.get_cmap('viridis')
1133+
ax=fig_test.add_subplot(111)
1134+
ax.imshow(zz,alpha=alpha,cmap=cmap,interpolation='nearest')
1135+
1136+
ax=fig_ref.add_subplot(111)
1137+
rgba=cmap(colors.Normalize()(zz))
1138+
rgba[...,-1]=alpha
1139+
ax.imshow(rgba,interpolation='nearest')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp