Skip to content

Commit

Permalink
randn method for ts objects and more rand constructor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dysonance committed Dec 12, 2017
1 parent 1eb7012 commit 3e3465d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3e3465d

Please sign in to comment.