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

Commit4760953

Browse files
committed
FIX: Include 0 when checking lognorm vmin
Change vmin check to less than or equal to 0 rather than strictlyless than.
1 parent2a3037f commit4760953

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

‎lib/matplotlib/image.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
532532
# we have re-set the vmin/vmax to account for small errors
533533
# that may have moved input values in/out of range
534534
s_vmin,s_vmax=vrange
535-
ifisinstance(self.norm,mcolors.LogNorm):
536-
ifs_vmin<0:
537-
s_vmin=max(s_vmin,np.finfo(scaled_dtype).eps)
535+
ifisinstance(self.norm,mcolors.LogNorm)ands_vmin<=0:
536+
# Don't give 0 or negative values to LogNorm
537+
s_vmin=np.finfo(scaled_dtype).eps
538538
withcbook._setattr_cm(self.norm,
539539
vmin=s_vmin,
540540
vmax=s_vmax,

‎lib/matplotlib/tests/test_image.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ def test_imshow_quantitynd():
12341234

12351235

12361236
@check_figures_equal(extensions=['png'])
1237-
deftest_huge_range_log(fig_test,fig_ref):
1237+
deftest_huge_range_log_negative(fig_test,fig_ref):
12381238
data=np.full((5,5),-1,dtype=np.float64)
12391239
data[0:2, :]=1E20
12401240

@@ -1252,6 +1252,23 @@ def test_huge_range_log(fig_test, fig_ref):
12521252
interpolation='nearest',cmap=cmap)
12531253

12541254

1255+
@check_figures_equal(extensions=['png'])
1256+
deftest_huge_range_log(fig_test,fig_ref):
1257+
data=np.full((5,5),1,dtype=np.float64)
1258+
data[0:2, :]=1E20
1259+
1260+
ax=fig_test.subplots()
1261+
im=ax.imshow(data,norm=colors.LogNorm(vmin=1,vmax=data.max()),
1262+
interpolation='nearest',cmap='viridis')
1263+
1264+
data=np.full((5,5),1,dtype=np.float64)
1265+
data[0:2, :]=1000
1266+
1267+
ax=fig_ref.subplots()
1268+
im=ax.imshow(data,norm=colors.Normalize(vmin=1,vmax=data.max()),
1269+
interpolation='nearest',cmap='viridis')
1270+
1271+
12551272
@check_figures_equal()
12561273
deftest_spy_box(fig_test,fig_ref):
12571274
# setting up reference and test

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp