Skip to content

Commit

Permalink
TimeBucket -> ClosedInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
joshday committed Mar 16, 2020
1 parent 07b5111 commit d96aaf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/part.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ function Base.merge!(a::Centroid, b::Centroid, astat, bstat)
a
end

#-----------------------------------------------------------------------------# TimeBucket
mutable struct TimeBucket{T <: Dates.TimeType}
#-----------------------------------------------------------------------------# ClosedInterval
mutable struct ClosedInterval{T}
first::T
last::T
end
Base.show(io::IO, b::TimeBucket) = print(io, "TimeBucket: [$(b.first), $(b.last)]")
Base.in(x, bucket::TimeBucket) = bucket.first x bucket.last
Base.isless(a::TimeBucket, b::TimeBucket) = isless(a.first, b.first)
function Base.merge!(a::TimeBucket, b::TimeBucket)
Base.show(io::IO, b::ClosedInterval) = print(io, "ClosedInterval: [$(b.first), $(b.last)]")
Base.in(x, bucket::ClosedInterval) = bucket.first x bucket.last
Base.isless(a::ClosedInterval, b::ClosedInterval) = isless(a.first, b.first)
function Base.merge!(a::ClosedInterval, b::ClosedInterval)
a.first = min(a.first, b.first)
a.last = max(a.last, b.last)
a
Expand Down
2 changes: 1 addition & 1 deletion test/test_stats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ println(" > Part")
a, b = mergevals(Part(Counter(), OnlineStatsBase.Centroid(0.0)), zip(y,y), zip(y2,y2))
@test a.stat == b.stat

o = Part(Mean(), OnlineStatsBase.TimeBucket(today() - Day(10), today()))
o = Part(Mean(), OnlineStatsBase.ClosedInterval(today() - Day(10), today()))
fit!(o, today() => 10)
fit!(o, today() - Day(5) => 20)
@test value(value(o).stat) == 15.0
Expand Down

2 comments on commit d96aaf8

@joshday
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/11051

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.1 -m "<description of version>" d96aaf89c189bcfa88ce6998eeaf024f599de2eb
git push origin v1.1.1

Please sign in to comment.