Skip to content

Commit

Permalink
simplification (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Dec 22, 2023
1 parent e095b36 commit b380865
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,10 @@ extend_limits(vec, lims) = extend_limits(vec, lims, :identity)
unitless(x) = x # noop when Unitful is not loaded

function extend_limits(vec::AbstractVector, lims, scale::Union{Symbol,Function})
isempty(vec) && return is_auto(lims) ? autolims(lims) : lims

scale = scale_callback(scale)
mi, ma = as_float(extrema(lims))
if iszero(mi) && iszero(ma)
isempty(vec) && return is_auto(lims) ? autolims(lims) : lims
mi, ma = as_float(extrema(vec))
end
if mi == ma
Expand Down
2 changes: 1 addition & 1 deletion test/tst_common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end
@test UnicodePlots.extend_limits([1, 2, 3, 4], [0, 0]) (1.0, 4.0)
@test UnicodePlots.extend_limits([1, 2, 3, 4], [1, 1]) (0.0, 2.0)

@test UnicodePlots.extend_limits([], (-1, 2)) (-1, 2)
@test UnicodePlots.extend_limits([], (-1, 2)) (-1.0, 2.0)

@test UnicodePlots.is_auto((0, 0))
@test UnicodePlots.is_auto([0, 0])
Expand Down
6 changes: 3 additions & 3 deletions test/tst_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end
end

@testset "Term extension" begin
gridplot(map(i -> lineplot((-i):i), 1:5); show_placeholder = true) |> display
gridplot(map(i -> lineplot((-i):i), 1:3); layout = (2, nothing)) |> display
gridplot(map(i -> lineplot((-i):i), 1:3); layout = (nothing, 1)) |> display
show(devnull, gridplot(map(i -> lineplot((-i):i), 1:5); show_placeholder = true))
show(devnull, gridplot(map(i -> lineplot((-i):i), 1:3); layout = (2, nothing)))
show(devnull, gridplot(map(i -> lineplot((-i):i), 1:3); layout = (nothing, 1)))
end

0 comments on commit b380865

Please sign in to comment.