annotate test/Grids/grid_test.jl @ 1726:471a948cd2b2 rename_module

Rename project from Sbplib to Diffinitive
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Sat, 07 Sep 2024 12:11:53 -0700
parents 43aaf710463e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1269
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
1 using Test
1726
471a948cd2b2 Rename project from Sbplib to Diffinitive
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1529
diff changeset
2 using Diffinitive.Grids
471a948cd2b2 Rename project from Sbplib to Diffinitive
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1529
diff changeset
3 using Diffinitive.LazyTensors
1269
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
4 using StaticArrays
1245
6323d2fe3b4f Add stub files for tests
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
5
6323d2fe3b4f Add stub files for tests
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
6 @testset "Grid" begin
1269
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
7 struct DummyGrid{T,D} <: Grid{T,D} end
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
8
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
9 @test eltype(DummyGrid{Int, 2}) == Int
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
10 @test eltype(DummyGrid{Int, 2}()) == Int
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
11
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
12 @test ndims(DummyGrid{Int, 2}()) == 2
1272
3637daad71e8 Add function target_manifold_dim for Grid
Jonatan Werpers <jonatan@werpers.com>
parents: 1270
diff changeset
13
1332
ad31c1022e42 Rename function for coordinate size of a grid
Jonatan Werpers <jonatan@werpers.com>
parents: 1324
diff changeset
14 @test coordinate_size(DummyGrid{Int, 1}()) == 1
ad31c1022e42 Rename function for coordinate size of a grid
Jonatan Werpers <jonatan@werpers.com>
parents: 1324
diff changeset
15 @test coordinate_size(DummyGrid{SVector{3,Float64}, 2}()) == 3
1288
7de1df0aad6a Add component_type function to Grid
Jonatan Werpers <jonatan@werpers.com>
parents: 1279
diff changeset
16
1333
79a2193da5c1 Implement coordinate_size() and component_type() types
Jonatan Werpers <jonatan@werpers.com>
parents: 1332
diff changeset
17 @test coordinate_size(DummyGrid{SVector{3,Float64}, 2}) == 3
1511
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
18 end
1333
79a2193da5c1 Implement coordinate_size() and component_type() types
Jonatan Werpers <jonatan@werpers.com>
parents: 1332
diff changeset
19
1511
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
20 @testset "component_type" begin
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
21 @test component_type(DummyGrid{Int,1}()) == Int
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
22 @test component_type(DummyGrid{Float64,1}()) == Float64
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
23 @test component_type(DummyGrid{Rational,1}()) == Rational
1288
7de1df0aad6a Add component_type function to Grid
Jonatan Werpers <jonatan@werpers.com>
parents: 1279
diff changeset
24
1511
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
25 @test component_type(DummyGrid{SVector{3,Int},2}()) == Int
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
26 @test component_type(DummyGrid{SVector{2,Float64},3}()) == Float64
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
27 @test component_type(DummyGrid{SVector{4,Rational},4}()) == Rational
1333
79a2193da5c1 Implement coordinate_size() and component_type() types
Jonatan Werpers <jonatan@werpers.com>
parents: 1332
diff changeset
28
1511
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
29 @test component_type(DummyGrid{Float64,1}) == Float64
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
30 @test component_type(DummyGrid{SVector{2,Float64},3}) == Float64
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
31
d50ea06813d5 Move and extend tests to reflect that component_type is more general than before
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
32 @test component_type(fill(@SVector[1,2], 4,2)) == Int
1245
6323d2fe3b4f Add stub files for tests
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
33 end
6323d2fe3b4f Add stub files for tests
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
34
6323d2fe3b4f Add stub files for tests
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
35 @testset "eval_on" begin
1269
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
36 @test eval_on(ZeroDimGrid(@SVector[1.,2.]), x̄->x̄[1]+x̄[2]) isa LazyArray
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
37 @test eval_on(ZeroDimGrid(@SVector[1.,2.]), x̄->x̄[1]+x̄[2]) == fill(3.)
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
38 @test eval_on(ZeroDimGrid(@SVector[3.,2.]), x̄->x̄[1]+x̄[2]) == fill(5.)
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
39
1279
1157f889bf50 Clear out some TBDs
Jonatan Werpers <jonatan@werpers.com>
parents: 1276
diff changeset
40 @test eval_on(ZeroDimGrid(1.), x̄->2x̄) isa LazyArray
1157f889bf50 Clear out some TBDs
Jonatan Werpers <jonatan@werpers.com>
parents: 1276
diff changeset
41 @test eval_on(ZeroDimGrid(1.), x̄->2x̄) == fill(2.)
1157f889bf50 Clear out some TBDs
Jonatan Werpers <jonatan@werpers.com>
parents: 1276
diff changeset
42
1397
86026367a9ff Support evaluating scalars on grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1343
diff changeset
43 @test eval_on(ZeroDimGrid(@SVector[1.,2.]), π) isa LazyArray
86026367a9ff Support evaluating scalars on grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1343
diff changeset
44 @test eval_on(ZeroDimGrid(@SVector[1.,2.]), π) == fill(π)
86026367a9ff Support evaluating scalars on grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1343
diff changeset
45
1269
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
46 @test eval_on(EquidistantGrid(range(0,1,length=4)), x->2x) isa LazyArray
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
47 @test eval_on(EquidistantGrid(range(0,1,length=4)), x->2x) == 2 .* range(0,1,length=4)
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
48
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
49
1529
43aaf710463e Change to signature of equidistant_grid to same style as many array methods.
Jonatan Werpers <jonatan@werpers.com>
parents: 1518
diff changeset
50 g = equidistant_grid((0.0,0.0), (2.0,1.0), 5, 3)
1252
c150eabaf656 Fix or mark tests broken where needed
Jonatan Werpers <jonatan@werpers.com>
parents: 1245
diff changeset
51
1269
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
52 @test eval_on(g, x̄ -> 0.) isa LazyArray
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
53 @test eval_on(g, x̄ -> 0.) == fill(0., (5,3))
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
54
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
55 @test eval_on(g, x̄ -> sin(x̄[1])*cos(x̄[2])) == map(x̄->sin(x̄[1])*cos(x̄[2]), g)
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
56
1397
86026367a9ff Support evaluating scalars on grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1343
diff changeset
57 @test eval_on(g, π) == fill(π, (5,3))
86026367a9ff Support evaluating scalars on grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1343
diff changeset
58
1269
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
59 # Vector valued function
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
60 @test eval_on(g, x̄ -> @SVector[x̄[2], x̄[1]]) isa LazyArray{SVector{2,Float64}}
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
61 @test eval_on(g, x̄ -> @SVector[x̄[2], x̄[1]]) == map(x̄ -> @SVector[x̄[2], x̄[1]], g)
20f42cf0800c Add test for Grid and make them pass. Start implementing eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1252
diff changeset
62
1273
7fab13c07412 Allow multi-argument functions in eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1272
diff changeset
63 # Multi-argument functions
1252
c150eabaf656 Fix or mark tests broken where needed
Jonatan Werpers <jonatan@werpers.com>
parents: 1245
diff changeset
64 f(x,y) = sin(x)*cos(y)
1273
7fab13c07412 Allow multi-argument functions in eval_on
Jonatan Werpers <jonatan@werpers.com>
parents: 1272
diff changeset
65 @test eval_on(g, f) == map(x̄->f(x̄...), g)
1245
6323d2fe3b4f Add stub files for tests
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
66 end
6323d2fe3b4f Add stub files for tests
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
67
1474
276c38a48aac Start implementing componentview
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
68 @testset "componentview" begin
276c38a48aac Start implementing componentview
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
69 v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
276c38a48aac Start implementing componentview
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
70
1515
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
71 @test componentview(v, 1, 1) isa AbstractArray
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
72 @test componentview(v, 1, :) isa AbstractArray
1476
62f9d0387a2a Introduce a view type and implement sliced indexing for the components.
Jonatan Werpers <jonatan@werpers.com>
parents: 1474
diff changeset
73
62f9d0387a2a Introduce a view type and implement sliced indexing for the components.
Jonatan Werpers <jonatan@werpers.com>
parents: 1474
diff changeset
74 A = @SMatrix[
1515
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
75 1 4 7;
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
76 2 5 8;
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
77 3 6 9;
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
78 ]
1476
62f9d0387a2a Introduce a view type and implement sliced indexing for the components.
Jonatan Werpers <jonatan@werpers.com>
parents: 1474
diff changeset
79 v = [A .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
1515
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
80 @test componentview(v, 2:3, 1:2) isa AbstractArray
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
81
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
82 # Correctness of the result is tested in ArrayComponentView
1476
62f9d0387a2a Introduce a view type and implement sliced indexing for the components.
Jonatan Werpers <jonatan@werpers.com>
parents: 1474
diff changeset
83 end
62f9d0387a2a Introduce a view type and implement sliced indexing for the components.
Jonatan Werpers <jonatan@werpers.com>
parents: 1474
diff changeset
84
62f9d0387a2a Introduce a view type and implement sliced indexing for the components.
Jonatan Werpers <jonatan@werpers.com>
parents: 1474
diff changeset
85 @testset "ArrayComponentView" begin
62f9d0387a2a Introduce a view type and implement sliced indexing for the components.
Jonatan Werpers <jonatan@werpers.com>
parents: 1474
diff changeset
86 v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
62f9d0387a2a Introduce a view type and implement sliced indexing for the components.
Jonatan Werpers <jonatan@werpers.com>
parents: 1474
diff changeset
87
1509
cfc24f132641 Add testset to clarify the purpose of equality tests
Jonatan Werpers <jonatan@werpers.com>
parents: 1490
diff changeset
88 @testset "==" begin
cfc24f132641 Add testset to clarify the purpose of equality tests
Jonatan Werpers <jonatan@werpers.com>
parents: 1490
diff changeset
89 @test ArrayComponentView(v, (1,1)) == ArrayComponentView(v, (1,1))
cfc24f132641 Add testset to clarify the purpose of equality tests
Jonatan Werpers <jonatan@werpers.com>
parents: 1490
diff changeset
90 @test ArrayComponentView(v, (1,1)) == ArrayComponentView(copy(v), (1,1))
cfc24f132641 Add testset to clarify the purpose of equality tests
Jonatan Werpers <jonatan@werpers.com>
parents: 1490
diff changeset
91 @test ArrayComponentView(v, (1,1)) == [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
cfc24f132641 Add testset to clarify the purpose of equality tests
Jonatan Werpers <jonatan@werpers.com>
parents: 1490
diff changeset
92 @test [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] == ArrayComponentView(v, (1,1))
cfc24f132641 Add testset to clarify the purpose of equality tests
Jonatan Werpers <jonatan@werpers.com>
parents: 1490
diff changeset
93 end
1515
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
94
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
95 @testset "components" begin
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
96 v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
97
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
98 @test ArrayComponentView(v, (1, 1)) == [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
99 @test ArrayComponentView(v, (1, 2)) == [3 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
100 @test ArrayComponentView(v, (2, 1)) == [2 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
101
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
102 @test ArrayComponentView(v, (1, :)) == [@SVector[1,3] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
103 @test ArrayComponentView(v, (2, :)) == [@SVector[2,4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
104 @test ArrayComponentView(v, (:, 1)) == [@SVector[1,2] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
105 @test ArrayComponentView(v, (:, 2)) == [@SVector[3,4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
106
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
107
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
108 A = @SMatrix[
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
109 1 4 7;
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
110 2 5 8;
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
111 3 6 9;
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
112 ]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
113 v = [A .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
114 @test ArrayComponentView(v, (1:2, 1:2)) == [@SMatrix[1 4;2 5] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
115 @test ArrayComponentView(v, (2:3, 1:2)) == [@SMatrix[2 5;3 6] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
b2eaa1ad19c8 Move correctness tests of componentview to the tests for ArrayComponentView
Jonatan Werpers <jonatan@werpers.com>
parents: 1509
diff changeset
116 end
1474
276c38a48aac Start implementing componentview
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
117 end
276c38a48aac Start implementing componentview
Jonatan Werpers <jonatan@werpers.com>
parents: 1397
diff changeset
118
1270
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
119 @testset "_ncomponents" begin
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
120 @test Grids._ncomponents(Int) == 1
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
121 @test Grids._ncomponents(Float64) == 1
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
122 @test Grids._ncomponents(Rational) == 1
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
123
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
124 @test Grids._ncomponents(SVector{3,Int}) == 3
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
125 @test Grids._ncomponents(SVector{2,Float64}) == 2
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
126 @test Grids._ncomponents(SVector{4,Rational}) == 4
dcbac783e4c1 Factor out functions for getting the type and number of components in a type
Jonatan Werpers <jonatan@werpers.com>
parents: 1269
diff changeset
127 end