-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support TimeSpans interface to go back to continuous time #9
Conversation
Codecov Report
@@ Coverage Diff @@
## main #9 +/- ##
==========================================
+ Coverage 92.75% 94.36% +1.61%
==========================================
Files 4 4
Lines 69 71 +2
==========================================
+ Hits 64 67 +3
+ Misses 5 4 -1
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
@palday rm'd the request for your review to comply with our <= 2 reviewers policy, but your feedback is always appreciated of course :) |
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.
Nice job! This is definetly an important issue. I tried my best to understand all aspects.
I made some suggestions to the documenation to be easier to understand for first-time-users.
One rounding mode seemed to have a missleading name to me, but I am not shure if it is possible to change that due already existing symbol names. One of the tests seems to have a glitch.
docs/src/index.md
Outdated
|
||
* `EndpointRoundingMode`: consists of a `RoundingMode` for the `start` and `stop` of the span. | ||
* The alias `RoundInward = EndpointRoundingMode(RoundUp, RoundDown)`, for example, constructs the largest span (whose endpoints are valid indices) that is entirely contained within `span`. | ||
* The alias `RoundEndsDown = EndpointRoundingMode(RoundDown, RoundDown)` matches the rounding semantics of `TimeSpans.index_from_time(sample_rate, span)`. |
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.
* The alias `RoundEndsDown = EndpointRoundingMode(RoundDown, RoundDown)` matches the rounding semantics of `TimeSpans.index_from_time(sample_rate, span)`. | |
* The alias `RoundDown = EndpointRoundingMode(RoundDown, RoundDown)` matches the rounding semantics of `TimeSpans.index_from_time(sample_rate, span)`. |
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.
When reading RoundEndsDown I expected that only the end time is rounded down. Maybe this alias is more intuitive.
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.
Not shure if there is now a symbol clash as RoundDown
was existing before?
src/AlignedSpans.jl
Outdated
@@ -40,6 +43,11 @@ end | |||
const RoundInward = EndpointRoundingMode(RoundUp, RoundDown) | |||
const RoundEndsDown = EndpointRoundingMode(RoundDown, RoundDown) |
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.
const RoundEndsDown = EndpointRoundingMode(RoundDown, RoundDown) | |
const RoundDown = EndpointRoundingMode(RoundDown, RoundDown) |
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.
I am leaving the decision to rename to you. For me it seems more clear to use rounddown.
Other files will need that change too.
test/interop.jl
Outdated
for sample_rate in [1.0, 0.5, 100.0, 128.33] | ||
# AlignedSpan -> TimeSpan -> AlignedSpan | ||
for (i, j) in [1 => 10, 5 => 20, 3 => 6, 78 => 79] | ||
for mode in (RoundEndsDown, RoundInward, ConstantSamplesRoundingMode) |
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.
Not shure if this is the correct test: should't mode
used in constructing the reference object? Now RoundEndsDown is used always
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.
Oops, that's right! Hopefully the test still passes 😅
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.
It does not, so I had to weaken it a bit
Co-authored-by: Franz Fürbass <[email protected]>
Thanks for the review @franzfurbass! Regarding julia> round(Int, 1.8, RoundDown)
1 We could use the same object to represent rounding both endpoints down, but I thought that was kind of a bad pun to use To me, I hoped plural What about |
The thing that dropped my out was the "endpoint" in the name. The rounding mode of TimeSpans rounds down the startpoint and the endpoint of the timespan. This naming convention is also used for maybe |
What about |
Sounds good! |
@franzfurbass if you're happy with the PR now, can you leave an "approval" review? That does 2 things:
|
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.
Sorry, forgot to submit the review. Thanks!
closes #7
Decided to use
TimeSpans.duration
instead of our own duration function here (in contrast to in #2), since nowAlignedSpans
are TimeSpans.jl-compatible timespans, so it's weird for them to have their own duration.I think this is slightly breaking because
TimeSpans.istimespan
changed values, and now we useTimeSpans.duration
instead ofAlignedSpans.duration
.editorial note: I'm pretty excited about this bc I think it's the "right" choice (finally), but most likely only time/usage will be able to really tell if it's "good".
Some more background for reviewers:
TimeSpans.jl is a library for defining an interface for representing continous time spans. It also has some functionality for getting indicies out (
index_from_time
,time_from_index
). It will probably help to see the TimeSpans docs, and TimeSpans#26 ,and maybe TimeSpans#2. It could also help to check out #2.