Skip to content

Commit

Permalink
fix rounding for ℯ based log
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Jun 28, 2021
1 parent 78b7041 commit 40868b0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ticks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ function optimize_ticks_typed(x_min::T, x_max::T, extend_ticks,
x_digits = bounding_order_of_magnitude(max(abs(x_min), abs(x_max)), base)
q_extra_digits = maximum(postdecimal_digits(q[1]) for q in Q)
sigdigits(z) = max(1, x_digits - z + q_extra_digits)
round_base(v) = isinteger(base) ? round(v, sigdigits=sigdigits(z), base=Int(base)) : round(v, sigdigits=sigdigits(z))

high_score = -Inf
S_best = Array{typeof(1.0 * one_t)}(undef, 1)
Expand Down Expand Up @@ -207,8 +208,8 @@ function optimize_ticks_typed(x_min::T, x_max::T, extend_ticks,
end
# round only those values that end up as viewmin and viewmax
# to save computation time
S[k + 1] = round(S[k + 1], sigdigits=sigdigits(z), base=Int(base))
S[2 * k] = round(S[2 * k], sigdigits=sigdigits(z), base=Int(base))
S[k + 1] = round_base(S[k + 1])
S[2 * k] = round_base(S[2 * k])
viewmin, viewmax = S[k + 1], S[2 * k]
else
S = prealloc_Ss[ik]
Expand All @@ -217,8 +218,8 @@ function optimize_ticks_typed(x_min::T, x_max::T, extend_ticks,
end
# round only those values that end up as viewmin and viewmax
# to save computation time
S[1] = round(S[1], sigdigits=sigdigits(z), base=Int(base))
S[k] = round(S[k], sigdigits=sigdigits(z), base=Int(base))
S[1] = round_base(S[1])
S[k] = round_base(S[k])
viewmin, viewmax = S[1], S[k]
end
if strict_span
Expand Down

0 comments on commit 40868b0

Please sign in to comment.