Mercurial > repos > public > sbplib_julia
comparison test/Grids/manifolds_test.jl @ 1903:04c251bccbd4 feature/grids/manifolds
Merge feature/grids/parameter_spaces
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 01 Feb 2025 22:17:39 +0100 |
parents | 27534b471b6a |
children | e7f8d11c4670 |
comparison
equal
deleted
inserted
replaced
1901:edee7d677efb | 1903:04c251bccbd4 |
---|---|
1 using Test | 1 using Test |
2 | 2 |
3 using Diffinitive.Grids | 3 using Diffinitive.Grids |
4 using Diffinitive.RegionIndices | 4 using Diffinitive.RegionIndices |
5 using Diffinitive.LazyTensors | 5 using Diffinitive.LazyTensors |
6 | |
7 # using StaticArrays | |
8 | |
9 @testset "ParameterSpace" begin | |
10 @test ndims(HyperBox([1,1], [2,2])) == 2 | |
11 @test ndims(unittetrahedron()) == 3 | |
12 end | |
13 | |
14 @testset "Interval" begin | |
15 @test Interval <: ParameterSpace{1} | |
16 | |
17 @test Interval(0,1) isa Interval{Int} | |
18 @test Interval(0,1.) isa Interval{Float64} | |
19 | |
20 @test unitinterval() isa Interval{Float64} | |
21 @test unitinterval() == Interval(0.,1.) | |
22 @test limits(unitinterval()) == (0.,1.) | |
23 | |
24 @test unitinterval(Int) isa Interval{Int} | |
25 @test unitinterval(Int) == Interval(0,1) | |
26 @test limits(unitinterval(Int)) == (0,1) | |
27 end | |
28 | |
29 @testset "HyperBox" begin | |
30 @test HyperBox{<:Any, 2} <: ParameterSpace{2} | |
31 @test HyperBox([1,1], [2,2]) isa HyperBox{Int, 2} | |
32 | |
33 @test HyperBox([1,2], [1.,2.]) isa HyperBox{Float64,2} | |
34 | |
35 @test limits(HyperBox([1,2], [3,4])) == ([1,2], [3,4]) | |
36 @test limits(HyperBox([1,2], [3,4]), 1) == (1,3) | |
37 @test limits(HyperBox([1,2], [3,4]), 2) == (2,4) | |
38 | |
39 @test unitsquare() isa HyperBox{Float64,2} | |
40 @test limits(unitsquare()) == ([0,0],[1,1]) | |
41 | |
42 @test unitcube() isa HyperBox{Float64,3} | |
43 @test limits(unitcube()) == ([0,0,0],[1,1,1]) | |
44 | |
45 @test unithyperbox(4) isa HyperBox{Float64,4} | |
46 @test limits(unithyperbox(4)) == ([0,0,0,0],[1,1,1,1]) | |
47 end | |
48 | |
49 @testset "Simplex" begin | |
50 @test Simplex{<:Any, 3} <: ParameterSpace{3} | |
51 @test Simplex([1,2], [3,4]) isa Simplex{Int, 2} | |
52 @test Simplex([1,2,3], [4,5,6],[1,1,1]) isa Simplex{Int, 3} | |
53 | |
54 @test Simplex([1,2], [3.,4.]) isa Simplex{Float64, 2} | |
55 | |
56 @test verticies(Simplex([1,2], [3,4])) == ([1,2], [3,4]) | |
57 | |
58 @test unittriangle() isa Simplex{Float64,2} | |
59 @test verticies(unittriangle()) == ([0,0], [1,0], [0,1]) | |
60 | |
61 @test unittetrahedron() isa Simplex{Float64,3} | |
62 @test verticies(unittetrahedron()) == ([0,0,0], [1,0,0], [0,1,0],[0,0,1]) | |
63 | |
64 @test unitsimplex(4) isa Simplex{Float64,4} | |
65 end | |
66 | 6 |
67 @testset "Chart" begin | 7 @testset "Chart" begin |
68 c = Chart(x->2x, unitsquare()) | 8 c = Chart(x->2x, unitsquare()) |
69 @test c isa Chart{2} | 9 @test c isa Chart{2} |
70 @test c([3,2]) == [6,4] | 10 @test c([3,2]) == [6,4] |