-
Notifications
You must be signed in to change notification settings - Fork 1
Support AlignedSpans #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #13 +/- ##
==========================================
+ Coverage 89.50% 89.83% +0.32%
==========================================
Files 1 1
Lines 162 177 +15
==========================================
+ Hits 145 159 +14
- Misses 17 18 +1
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
ericphanson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is explicit support necessary? What do we need to do in AlignedSpans so it isn't?
AlignedSpans already support TimeSpans.istimespan, TimeSpans.start and TimeSpans.stop. We could add an Intervals constructor as well if that would help.
|
Good question! I think, short term, that this PR is the easiest path forward. But I think making the support more generic is a good idea. I've opened #17. |
|
We could add a constructor like function Intervals.Interval{Nanosecond, Closed, Open}(span::AlignedSpan)
L = time_from_index(span.sample_rate, span.first_index)
R = time_from_index(span.sample_rate, span.last_index+1)
return Interval{Nanosecond, Closed, Open}(L, R)
endand even also function Intervals.Interval{Nanosecond, Closed, Closed}(span::AlignedSpan)
L = time_from_index(span.sample_rate, span.first_index)
R = time_from_index(span.sample_rate, span.last_index)
return Interval{Nanosecond, Closed, Closed}(L, R)
endto TimeSpans.
Ah, that seems harder to do generically. I'm not sure if there's a reaosnable way to support it without the explicit support. I am not a fan of Requires though; e.g. SciML style says
I have heard lots of folks have various issues with it, including load time regressions, and there are scary-looking unaddressed issues like JuliaPackaging/Requires.jl#83. |
|
I agree that |
|
Since AlignedSpan's roundtrips w/ TimeSpans, what about something like this? using DataFrameIntervals
using TimeSpans
using DataFrameIntervals: Interval, IntervalArray, interval, backto
function DataFrameIntervals.interval(x::AlignedSpan)
return interval(TimeSpan(x))
end
function DataFrameIntervals.backto(x::AlignedSpan, x_::Interval)
return AlignedSpan(x.sample_rate, backto(TimeSpan(x), x_), RoundSpanDown)
end
function DataFrameIntervals.IntervalArray(x::AbstractVector{<:AlignedSpan})
return IntervalArray(TimeSpan.(x))
end |
|
Ah! Yeah, that seems like a good interim approach! And would mean we don't have to wait until |
|
I would suggest treating this approach as stale and if we want explicit support, using package extensions |
This adds support for specifying intervals of time using
AlignedSpans