From de59735909bae5b70efaed11971140cdb1ce3dc0 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 18 Jul 2022 13:56:54 +0200 Subject: [PATCH 1/3] rm duplicated code --- test/runtests.jl | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 00cd045..404b911 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,20 +13,6 @@ function make_test_samples(sample_rate) sample_rate), false) end -# Interop with `StepRange` -function Base.StepRange(span::AlignedSpan) - # the rounding here is not ideal - t = Nanosecond(round(Int, TimeSpans.nanoseconds_per_sample(span.sample_rate))) - return (span.i * t):t:(span.j * t) -end - -function AlignedSpan(r::StepRange{T,S}) where {T<:Period,S<:Period} - sample_rate = TimeSpans.NS_IN_SEC / Dates.value(convert(Nanosecond, step(r))) - i = first(r) / step(r) - j = last(r) / step(r) - return AlignedSpan(sample_rate, Int(i), Int(j)) -end - @testset "AlignedSpans.jl" begin @testset "Aqua" begin Aqua.test_all(AlignedSpans; ambiguities=false) From 2db6ee8376ec4453ef5ef0495d6397548d11da95 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 18 Jul 2022 14:04:23 +0200 Subject: [PATCH 2/3] rm broken method and add test --- src/interop.jl | 1 - test/runtests.jl | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/interop.jl b/src/interop.jl index 268f6e7..4cb65c2 100644 --- a/src/interop.jl +++ b/src/interop.jl @@ -47,7 +47,6 @@ TimeSpans.stop(span::AlignedSpan) = time_from_index(span.sample_rate, span.last_ # TimeSpan -> AlignedSpan is supported by passing to Intervals to_interval(span) = Interval{Nanosecond,Closed,Open}(start(span), stop(span)) to_interval(span::Interval) = span -to_interval(span::AlignedSpan) = Interval(span) # Interface methods: diff --git a/test/runtests.jl b/test/runtests.jl index 404b911..ee24687 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -56,6 +56,9 @@ end span = TimeSpan(Millisecond(1999), Millisecond(2000)) aligned = AlignedSpan(1, span, RoundSpanDown) @test indices(aligned) == 2:2 + + # Test that we can pass an `AlignedSpan` back into the constructor + @test AlignedSpan(1, aligned, RoundSpanDown) == aligned end @testset "ConstantSamplesRoundingMode" begin From 32114e08b6a51e87f1f7c19c32271801d48d9945 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 18 Jul 2022 14:04:33 +0200 Subject: [PATCH 3/3] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index db0115d..f682c72 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AlignedSpans" uuid = "72438786-fd5d-49ef-8843-650acbdfe662" authors = ["Beacon Biosignals, Inc."] -version = "0.2.0" +version = "0.2.1" [deps] ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"