From 6b28ae57f163843f5239ba0bf252dbd34268c400 Mon Sep 17 00:00:00 2001 From: ffreyer Date: Mon, 4 Mar 2024 17:19:27 +0100 Subject: [PATCH 1/5] adjust limit for fallback_ticks --- src/ticks.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ticks.jl b/src/ticks.jl index cfb0ed2..8f7d10c 100644 --- a/src/ticks.jl +++ b/src/ticks.jl @@ -154,7 +154,9 @@ function optimize_ticks( span_buffer = nothing, scale = nothing, ) where {T} - x_min ≈ x_max && return fallback_ticks(x_min, x_max, k_min, k_max, strict_span) + if isapprox(x_min, x_max, rtol = 1000.0 * eps(T)) + return fallback_ticks(x_min, x_max, k_min, k_max, strict_span) + end F = float(T) Qv = F[q[1] for q ∈ Q] From 1271d45cb2a9a9178ac988985b485255304360b5 Mon Sep 17 00:00:00 2001 From: ffreyer Date: Mon, 4 Mar 2024 18:39:28 +0100 Subject: [PATCH 2/5] fix Integer inputs --- src/ticks.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ticks.jl b/src/ticks.jl index 8f7d10c..f17f43d 100644 --- a/src/ticks.jl +++ b/src/ticks.jl @@ -154,7 +154,9 @@ function optimize_ticks( span_buffer = nothing, scale = nothing, ) where {T} - if isapprox(x_min, x_max, rtol = 1000.0 * eps(T)) + + rtol = T isa AbstractFloat ? 1000.0 * eps(T) : Base.rtoldefault(x_min, x_max, 0) + if isapprox(x_min, x_max, rtol = rtol) return fallback_ticks(x_min, x_max, k_min, k_max, strict_span) end From 924907f79fdc957bdc78985477deca9273ed74e2 Mon Sep 17 00:00:00 2001 From: ffreyer Date: Mon, 4 Mar 2024 20:42:25 +0100 Subject: [PATCH 3/5] fix typo and add test --- src/ticks.jl | 2 +- test/runtests.jl | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ticks.jl b/src/ticks.jl index f17f43d..7208184 100644 --- a/src/ticks.jl +++ b/src/ticks.jl @@ -155,7 +155,7 @@ function optimize_ticks( scale = nothing, ) where {T} - rtol = T isa AbstractFloat ? 1000.0 * eps(T) : Base.rtoldefault(x_min, x_max, 0) + rtol = T <: AbstractFloat ? 1000.0 * eps(T) : Base.rtoldefault(x_min, x_max, 0) if isapprox(x_min, x_max, rtol = rtol) return fallback_ticks(x_min, x_max, k_min, k_max, strict_span) end diff --git a/test/runtests.jl b/test/runtests.jl index 551d822..d26c6b2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -119,6 +119,10 @@ end @testset "ticks" begin @test optimize_ticks(-1, 2) == ([-1.0, 0.0, 1.0, 2.0], -1.0, 2.0) + # check if ticks still generate if max - min << abs(min) (i.e. for Float64 ranges) + @test optimize_ticks(1e11 - 1, 1e11 + 2) == (1e11 .+ (-1:2), 1e11 - 1.0, 1e11 + 2.0) + + @testset "dates" begin dt1, dt2 = Dates.value(DateTime(2000)), Dates.value(DateTime(2100)) @test optimize_datetime_ticks(dt1, dt2) == ( From bd9b6cd9ac888da66e915b5c7a0b85fe66b23622 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Mon, 4 Mar 2024 21:17:03 -0500 Subject: [PATCH 4/5] Fix formatting --- src/ticks.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ticks.jl b/src/ticks.jl index 7208184..1d7e9e4 100644 --- a/src/ticks.jl +++ b/src/ticks.jl @@ -154,7 +154,6 @@ function optimize_ticks( span_buffer = nothing, scale = nothing, ) where {T} - rtol = T <: AbstractFloat ? 1000.0 * eps(T) : Base.rtoldefault(x_min, x_max, 0) if isapprox(x_min, x_max, rtol = rtol) return fallback_ticks(x_min, x_max, k_min, k_max, strict_span) From e9a04919884a4ee28b1a3be56bfe7fa2d9e77953 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Mon, 4 Mar 2024 23:03:19 -0500 Subject: [PATCH 5/5] Remove extra newline --- test/runtests.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index d26c6b2..1e779c7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -122,7 +122,6 @@ end # check if ticks still generate if max - min << abs(min) (i.e. for Float64 ranges) @test optimize_ticks(1e11 - 1, 1e11 + 2) == (1e11 .+ (-1:2), 1e11 - 1.0, 1e11 + 2.0) - @testset "dates" begin dt1, dt2 = Dates.value(DateTime(2000)), Dates.value(DateTime(2100)) @test optimize_datetime_ticks(dt1, dt2) == (