Skip to content

Commit

Permalink
fix cornercase
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Oct 11, 2024
1 parent a6f6f03 commit 25763d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,9 @@ 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
get(cdata, z01) |> ansi_color
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

0 comments on commit 25763d2

Please sign in to comment.