Skip to content
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

Fix AlignedSpan(..., ::AlignedSpan, ...) and add test #11

Merged
merged 3 commits into from
Jul 18, 2022
Merged

Conversation

ericphanson
Copy link
Member

Also removes some duplicated code in the tests (the same method is in runtests.jl and interop.jl).

I noticed these issues when looking at beacon-biosignals/DataFrameIntervals.jl#13

If we were to add an Interval(::AlignedSpan) constructor, I think the most natural one would be

function Intervals.Interval(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)
end

because an AlignedSpan really is a closed-closed interval of indices. However, we do support mapping to TimeSpans' closed-open world.

@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #11 (32114e0) into main (be2b363) will increase coverage by 1.34%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
+ Coverage   94.36%   95.71%   +1.34%     
==========================================
  Files           4        4              
  Lines          71       70       -1     
==========================================
  Hits           67       67              
+ Misses          4        3       -1     
Impacted Files Coverage Δ
src/interop.jl 92.85% <ø> (+3.20%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Comment on lines 49 to -50
to_interval(span::Interval) = span
to_interval(span::AlignedSpan) = Interval(span)
Copy link
Member

Choose a reason for hiding this comment

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

does this count as breaking?

Copy link
Member Author

Choose a reason for hiding this comment

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

No bc this actually errored (no such Interval constructor existed), but removing this dispatch means we hit the fallback which works successfully (as the test shows).

@ericphanson ericphanson merged commit 3bd5624 into main Jul 18, 2022
@ericphanson ericphanson deleted the eph/cleanup branch July 18, 2022 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants