beacon-biosignals / AlignedSpans.jl

Helpers for continuous <-> discrete indexing
MIT License
4 stars 0 forks source link

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

Closed ericphanson closed 2 years ago

ericphanson commented 2 years ago

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 https://github.com/beacon-biosignals/DataFrameIntervals.jl/pull/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[bot] commented 2 years ago

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%) :arrow_up:

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