From 3e3465df293eb6fb7f9c4f752902fbbf40342d04 Mon Sep 17 00:00:00 2001 From: dysonance Date: Tue, 12 Dec 2017 07:37:11 -0500 Subject: [PATCH] randn method for ts objects and more rand constructor tests --- src/operations.jl | 4 ++++ test/operations.jl | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/operations.jl b/src/operations.jl index e934120..a5ab708 100644 --- a/src/operations.jl +++ b/src/operations.jl @@ -47,6 +47,10 @@ rand(::Type{TS}, n::Int=1) = TS(rand(Float64, n)) rand(::Type{TS}, r::Int, c::Int) = TS(rand(Float64, r, c)) rand(::Type{TS}, dims::Tuple{Int,Int}) = TS(rand(Float64, dims)) +randn(::Type{TS}, n::Int=1) = TS(randn(Float64, n)) +randn(::Type{TS}, r::Int, c::Int) = TS(randn(Float64, r, c)) +randn(::Type{TS}, dims::Tuple{Int,Int}) = TS(randn(Float64, dims)) + trues(x::TS) = ts(trues(x.values), x.index, x.fields) falses(x::TS) = ts(falses(x.values), x.index, x.fields) isnan(x::TS) = ts(isnan.(x.values), x.index, x.fields) diff --git a/test/operations.jl b/test/operations.jl index 74950e8..a87923c 100644 --- a/test/operations.jl +++ b/test/operations.jl @@ -18,6 +18,11 @@ using Base.Test, Base.Dates, Temporal @test ones(x).values == ones(eltype(x), size(x)) @test zeros(x).values == zeros(eltype(x), size(x)) @test length(rand(TS,N)) == N + @test length(rand(TS,N,K)) == N*K + @test length(rand(TS,(N,K))) == N*K + @test length(randn(TS,N)) == N + @test length(randn(TS,N,K)) == N*K + @test length(randn(TS,(N,K))) == N*K x = ts(-1.0 .* rand(N)) y = +x @test all(y.values .<= 0.0)