Skip to content

Commit

Permalink
fix cornercase (#385)
Browse files Browse the repository at this point in the history
* fix cornercase

* format
  • Loading branch information
t-bltg authored Oct 11, 2024
1 parent a6f6f03 commit 4012b89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit 4012b89

Please sign in to comment.