Mercurial > repos > public > sbplib_julia
comparison test/Grids/equidistant_grid_test.jl @ 1437:e3a80ef08d09
Implement size(g,d) for EquidistantGrid and TensorGrid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 22 Nov 2023 17:34:35 +0100 |
parents | 1aa8adbf13d5 |
children | 05eb8ba149e2 |
comparison
equal
deleted
inserted
replaced
1421:69c9e6eae686 | 1437:e3a80ef08d09 |
---|---|
28 @test eltype(EquidistantGrid(0:10)) == Int | 28 @test eltype(EquidistantGrid(0:10)) == Int |
29 @test eltype(EquidistantGrid(0:2:10)) == Int | 29 @test eltype(EquidistantGrid(0:2:10)) == Int |
30 @test eltype(EquidistantGrid(0:0.1:10)) == Float64 | 30 @test eltype(EquidistantGrid(0:0.1:10)) == Float64 |
31 @test size(EquidistantGrid(0:10)) == (11,) | 31 @test size(EquidistantGrid(0:10)) == (11,) |
32 @test size(EquidistantGrid(0:0.1:10)) == (101,) | 32 @test size(EquidistantGrid(0:0.1:10)) == (101,) |
33 | |
34 @test size(EquidistantGrid(0:0.1:10),1) == 101 | |
33 | 35 |
34 @test collect(EquidistantGrid(0:0.1:0.5)) == [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] | 36 @test collect(EquidistantGrid(0:0.1:0.5)) == [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] |
35 | 37 |
36 @test Base.IteratorSize(EquidistantGrid{Float64, StepRange{Float64}}) == Base.HasShape{1}() | 38 @test Base.IteratorSize(EquidistantGrid{Float64, StepRange{Float64}}) == Base.HasShape{1}() |
37 end | 39 end |
105 @test_throws DomainError equidistant_grid((1,1),(1.0,1.0),(-1.0,-1.0)) | 107 @test_throws DomainError equidistant_grid((1,1),(1.0,1.0),(-1.0,-1.0)) |
106 | 108 |
107 @testset "Base" begin | 109 @testset "Base" begin |
108 @test eltype(equidistant_grid(4,0.0,1.0)) == Float64 | 110 @test eltype(equidistant_grid(4,0.0,1.0)) == Float64 |
109 @test eltype(equidistant_grid((4,3),(0,0),(1,3))) <: AbstractVector{Float64} | 111 @test eltype(equidistant_grid((4,3),(0,0),(1,3))) <: AbstractVector{Float64} |
112 | |
110 @test size(equidistant_grid(4,0.0,1.0)) == (4,) | 113 @test size(equidistant_grid(4,0.0,1.0)) == (4,) |
111 @test size(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0))) == (5,3) | 114 @test size(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0))) == (5,3) |
115 | |
116 @test size(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0)),1) == 5 | |
117 @test size(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0)),2) == 3 | |
118 | |
112 @test ndims(equidistant_grid(4,0.0,1.0)) == 1 | 119 @test ndims(equidistant_grid(4,0.0,1.0)) == 1 |
113 @test ndims(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0))) == 2 | 120 @test ndims(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0))) == 2 |
114 end | 121 end |
115 | 122 |
116 @testset "getindex" begin | 123 @testset "getindex" begin |