Skip to content

Commit 4012b89

Browse files
authored
fix cornercase (#385)
* fix cornercase * format
1 parent a6f6f03 commit 4012b89

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/common.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,11 @@ function colormap_callback(cmap::Symbol)
609609
cdata = ColorSchemes.colorschemes[cmap]
610610
(z, minz, maxz) -> begin
611611
isfinite(z) || return INVALID_COLOR
612-
get(
613-
cdata,
614-
minz == maxz ? zero(z) : (max(minz, min(z, maxz)) - minz) / (maxz - minz),
615-
) |> ansi_color
612+
z01 =
613+
minz == maxz ? zero(z) :
614+
(max(minz, min(z, maxz)) - minz) / (maxz - minz)
615+
isfinite(z01) || return INVALID_COLOR
616+
ansi_color(get(cdata, z01))
616617
end::ColorType
617618
end
618619

test/tst_issues.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,13 @@
107107
p = scatterplot(rand(1) * u"m", rand(1))
108108
show(devnull, p)
109109
end
110+
111+
@testset "Heatmap ±Inf (#378)" begin
112+
p = heatmap([1 2; 3 -Inf])
113+
show(devnull, p)
114+
p = heatmap([-Inf;;])
115+
show(devnull, p)
116+
p = heatmap([1 2; 3 Inf])
117+
show(devnull, p)
118+
end
110119
end

0 commit comments

Comments
 (0)