Mercurial > repos > public > sbplib_julia
comparison LazyTensors/test/runtests.jl @ 325:41c3c25e4e3b
LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 24 Sep 2020 22:31:04 +0200 |
parents | 277dff5b071a |
children |
comparison
equal
deleted
inserted
replaced
324:047dee8efaef | 325:41c3c25e4e3b |
---|---|
113 @test range_size(A+B, (3,)) == range_size(A, (3,)) == range_size(B,(3,)) | 113 @test range_size(A+B, (3,)) == range_size(A, (3,)) == range_size(B,(3,)) |
114 @test domain_size(A+B, (3,)) == domain_size(A, (3,)) == domain_size(B,(3,)) | 114 @test domain_size(A+B, (3,)) == domain_size(A, (3,)) == domain_size(B,(3,)) |
115 end | 115 end |
116 | 116 |
117 @testset "LazyArray" begin | 117 @testset "LazyArray" begin |
118 @testset "LazyConstantArray" begin | |
119 @test LazyTensors.LazyConstantArray(3,(3,2)) isa LazyArray{Int,2} | |
120 | |
121 lca = LazyTensors.LazyConstantArray(3.0,(3,2)) | |
122 @test eltype(lca) == Float64 | |
123 @test ndims(lca) == 2 | |
124 @test size(lca) == (3,2) | |
125 @test lca[2] == 3.0 | |
126 end | |
118 struct DummyArray{T,D, T1<:AbstractArray{T,D}} <: LazyArray{T,D} | 127 struct DummyArray{T,D, T1<:AbstractArray{T,D}} <: LazyArray{T,D} |
119 data::T1 | 128 data::T1 |
120 end | 129 end |
121 Base.size(v::DummyArray) = size(v.data) | 130 Base.size(v::DummyArray) = size(v.data) |
122 Base.getindex(v::DummyArray{T,D}, I::Vararg{Int,D}) where {T,D} = v.data[I...] | 131 Base.getindex(v::DummyArray{T,D}, I::Vararg{Int,D}) where {T,D} = v.data[I...] |