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

FIX: Include 0 when checking lognorm vmin#20488

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 1 commit intomatplotlib:masterfromgreglucas:fix-image-lognorm
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes fromall 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
6 changes: 3 additions & 3 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -532,9 +532,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
# we have re-set the vmin/vmax to account for small errors
# that may have moved input values in/out of range
s_vmin, s_vmax = vrange
if isinstance(self.norm, mcolors.LogNorm):
if s_vmin < 0:
s_vmin =max(s_vmin,np.finfo(scaled_dtype).eps)
if isinstance(self.norm, mcolors.LogNorm) and s_vmin <= 0:
# Don't give 0 or negative values to LogNorm
s_vmin = np.finfo(scaled_dtype).eps
with cbook._setattr_cm(self.norm,
vmin=s_vmin,
vmax=s_vmax,
Expand Down
19 changes: 10 additions & 9 deletionslib/matplotlib/tests/test_image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1233,23 +1233,24 @@ def test_imshow_quantitynd():
fig.canvas.draw()


@pytest.mark.parametrize('x', [-1, 1])
@check_figures_equal(extensions=['png'])
def test_huge_range_log(fig_test, fig_ref):
data = np.full((5, 5), -1, dtype=np.float64)
def test_huge_range_log(fig_test, fig_ref, x):
# parametrize over bad lognorm -1 values and large range 1 -> 1e20
data = np.full((5, 5), x, dtype=np.float64)
data[0:2, :] = 1E20

ax = fig_test.subplots()
im =ax.imshow(data, norm=colors.LogNorm(vmin=100, vmax=data.max()),
interpolation='nearest', cmap='viridis')
ax.imshow(data, norm=colors.LogNorm(vmin=1, vmax=data.max()),
interpolation='nearest', cmap='viridis')

data = np.full((5, 5),-1, dtype=np.float64)
data = np.full((5, 5),x, dtype=np.float64)
data[0:2, :] = 1000

cmap = copy(plt.get_cmap('viridis'))
cmap.set_under('w')
ax = fig_ref.subplots()
im = ax.imshow(data, norm=colors.Normalize(vmin=100, vmax=data.max()),
interpolation='nearest', cmap=cmap)
cmap = plt.get_cmap('viridis').with_extremes(under='w')
ax.imshow(data, norm=colors.Normalize(vmin=1, vmax=data.max()),
interpolation='nearest', cmap=cmap)


@check_figures_equal()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp