Skip to content

Commit

Permalink
Fix histogram guessing interval fore DateTime input
Browse files Browse the repository at this point in the history
  • Loading branch information
joa-quim committed Jan 28, 2021
1 parent c513262 commit ab62f3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/pshistogram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ function binmethod(d::Dict, cmd::String, X, is_datetime::Bool)
else
min_max = extrema(X) # X should already be sorted but don't trust that
rng = (min_max[2] - min_max[1])
if (rng / (86400 * 365.25) < 120) val = "year"
elseif (rng / (86400 * 31) < 120) val = "month"
elseif (rng / (86400 * 7) < 120) val = "week"
elseif (rng / (86400) < 120) val = "day"
elseif (rng / (3600) < 120) val = "hour"
elseif (rng / (60) < 120) val = "minute"
else val = "second"
if (rng < 150) val = "second"
elseif (rng / (60) < 150) val = "minute"
elseif (rng / (3600) < 150) val = "hour"
elseif (rng / (86400) < 150) val = "day"
elseif (rng / (86400 * 7) < 150) val = "week"
elseif (rng / (86400 * 31) < 150) val = "month"
else val = "year"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ if (got_it) # Otherwise go straight to end
histogram(G, Vd=dbg2);
histogram(G, T=0.3, Vd=dbg2);
histogram(rand(10), Vd=dbg2);
histogram(collect(Dates.DateTime(Dates.now()):Dates.Second(1):Dates.DateTime(Dates.now() + Dates.Hour(2) + Dates.Minute(1))))
histogram(collect(Dates.DateTime(Dates.now()):Dates.Month(6):Dates.DateTime(Dates.now() + Dates.Year(20))))
@test_throws ErrorException("Unknown BinMethod lala") histogram(rand(100), binmethod="lala")

println(" PSLEGEND")
Expand Down

0 comments on commit ab62f3e

Please sign in to comment.