diff --git a/src/mapsignal.jl b/src/mapsignal.jl index ca04a5c..32330aa 100644 --- a/src/mapsignal.jl +++ b/src/mapsignal.jl @@ -37,8 +37,6 @@ SignalTrait(x::Type{<:MapSignal{<:Any,<:Any,<:Any,T,Fs,L}}) where {Fs,T,L} = nchannels(x::MapSignal) = length(x.val) framerate(x::MapSignal) = x.framerate -isnumbers(::Tuple{<:Number}) = true -isnumbers(xs) = false function duration(x::MapSignal) durs = duration.(x.padded_signals) Ns = nframes_helper.(x.padded_signals) @@ -146,14 +144,13 @@ function OperateOn(fn,xs...; bychannel) end -maxlen(x::Extended,y::Number) = max(x.len,y) -maxlen(x::Extended,y::Extended) = max(x.len,y.len) -maxlen(x::Extended,y::Infinite) = x.len -maxlen(x::NumberExtended,y) = y -maxlen(x::NumberExtended,y::Extended) = y.len -maxlen(x,y) = max(x,y) -maxlen(x,y::Extended) = max(x,y.len) -maxlen(x,y::NumberExtended) = x +tolen(x::Extended) = x.len +tolen(x::Number) = x +tolen(x::NumberExtended) = 0 +tolen(x::InfiniteLength) = inflen +tolen(x::Missing) = missing +maxlen(x,y) = max(tolen(x),tolen(y)) +maxlen(x::NumberExtended,y::NumberExtended) = x nframes_helper(x::MapSignal) = reduce(maxlen,nframes_helper.(x.signals)) """ diff --git a/test/runtests.jl b/test/runtests.jl index a928e39..d9a31f3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -218,9 +218,15 @@ progress = Progress(total_test_groups,desc="Running tests...") @test Extend(x,one) |> nframes == inflen @test Mix(Extend(x,one),y) |> nframes == 15 + @test Mix(y,Extend(x,one)) |> nframes == 15 @test Mix(Pad(x,one),y) |> nframes |> isinf @test Mix(1,rand(10,2)) |> nframes == 10 + @test Mix(1,Extend(rand(10,2),zero)) |> nframes == 10 + @test Mix(rand(10,2),1) |> nframes == 10 + @test Mix(Extend(rand(10,2),zero),1) |> nframes == 10 @test Mix(sin,1,rand(10,2)) |> nframes |> isinf + @test Mix(1,sin,rand(10,2)) |> nframes |> isinf + @test Mix(1,rand(10,2),sin) |> nframes |> isinf end end next!(progress) @@ -629,6 +635,8 @@ progress = Progress(total_test_groups,desc="Running tests...") "100×2 Array{Float64,2}: … (10.0 Hz) |>\n Append(50×2 Array{Float64,2}: … (10.0 Hz))" @test x |> Pad(zero) |> showstring == "100×2 Array{Float64,2}: … (10.0 Hz) |> Pad(zero)" + @test x |> Extend(zero) |> showstring == + "100×2 Array{Float64,2}: … (10.0 Hz) |> Extend(zero)" @test x |> Filt(Lowpass,3Hz) |> showstring == "100×2 Array{Float64,2}: … (10.0 Hz) |> Filt(Lowpass,3 Hz)" @test x |> Normpower |> showstring ==