Skip to content

fix cornercase #385

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,11 @@ function colormap_callback(cmap::Symbol)
cdata = ColorSchemes.colorschemes[cmap]
(z, minz, maxz) -> begin
isfinite(z) || return INVALID_COLOR
get(
cdata,
minz == maxz ? zero(z) : (max(minz, min(z, maxz)) - minz) / (maxz - minz),
) |> ansi_color
z01 =
minz == maxz ? zero(z) :
(max(minz, min(z, maxz)) - minz) / (maxz - minz)
isfinite(z01) || return INVALID_COLOR
ansi_color(get(cdata, z01))
end::ColorType
end

Expand Down
9 changes: 9 additions & 0 deletions test/tst_issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,13 @@
p = scatterplot(rand(1) * u"m", rand(1))
show(devnull, p)
end

@testset "Heatmap ±Inf (#378)" begin
p = heatmap([1 2; 3 -Inf])
show(devnull, p)
p = heatmap([-Inf;;])
show(devnull, p)
p = heatmap([1 2; 3 Inf])
show(devnull, p)
end
end
Loading