Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Nov 5, 2024
1 parent 6e2bd3d commit b879041
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/Lookups/lookup_arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,15 @@ _bounds(::Intervals, span::Regular, lookup::AbstractSampled) =
_bounds(locus(lookup), order(lookup), span, lookup)
_bounds(::Start, ::ForwardOrdered, span::Regular, lookup) = first(lookup), last(lookup) + step(span)
_bounds(::Start, ::ReverseOrdered, span::Regular, lookup) = last(lookup), first(lookup) - step(span)
_bounds(::Center, ::ForwardOrdered, span::Regular, lookup) =
first(lookup) - step(span) / 2, last(lookup) + step(span) / 2
_bounds(::Center, ::ReverseOrdered, span::Regular, lookup) =
last(lookup) + step(span) / 2, first(lookup) - step(span) / 2
# DateTime handling
function _bounds(::Center, ::ForwardOrdered, span::Regular, lookup::Lookup{<:Dates.AbstractTime})
f, l, s = first(lookup), last(lookup), step(span)
(f - (f - (f - s)) / 2, l - (l - (l + s)) / 2)
function _bounds(::Center, order::Ordered, span::Regular, lookup)
bounds = first(lookup) - step(span) / 2, last(lookup) + step(span) / 2
return _maybeflipbounds(order, bounds)
end
function _bounds(::Center, ::ReverseOrdered, span::Regular, lookup::Lookup{<:Dates.AbstractTime})
# DateTime handling
function _bounds(::Center, order::Ordered, span::Regular, lookup::Lookup{<:Dates.AbstractTime})
f, l, s = first(lookup), last(lookup), step(span)
(l - (l - (l + s)) / 2, f - (f - (f - s)) / 2)
bounds = (f - (f - (f - s)) / 2, l - (l - (l + s)) / 2)
_maybeflipbounds(order, bounds)
end
_bounds(::End, ::ForwardOrdered, span::Regular, lookup) = first(lookup) - step(span), last(lookup)
_bounds(::End, ::ReverseOrdered, span::Regular, lookup) = last(lookup) + step(span), first(lookup)
Expand Down

0 comments on commit b879041

Please sign in to comment.