Mercurial > repos > public > sbplib_julia
comparison test/Grids/parameter_space_test.jl @ 2002:4300c59bbeff feature/grids/geometry_functions
Merge feature/grids/manifolds
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 29 Apr 2025 09:00:42 +0200 |
parents | e6dbd4bec6cc |
children |
comparison
equal
deleted
inserted
replaced
1983:730c9848ad0b | 2002:4300c59bbeff |
---|---|
1 using Test | 1 using Test |
2 | 2 |
3 using Diffinitive.Grids | 3 using Diffinitive.Grids |
4 using StaticArrays | |
4 | 5 |
5 @testset "ParameterSpace" begin | 6 @testset "ParameterSpace" begin |
6 @test ndims(HyperBox([1,1], [2,2])) == 2 | 7 @test ndims(HyperBox([1,1], [2,2])) == 2 |
7 @test ndims(unittetrahedron()) == 3 | 8 @test ndims(unittetrahedron()) == 3 |
8 end | 9 end |
20 @test unitinterval(Int) isa Interval{Int} | 21 @test unitinterval(Int) isa Interval{Int} |
21 @test unitinterval(Int) == Interval(0,1) | 22 @test unitinterval(Int) == Interval(0,1) |
22 @test limits(unitinterval(Int)) == (0,1) | 23 @test limits(unitinterval(Int)) == (0,1) |
23 | 24 |
24 @test boundary_identifiers(unitinterval()) == (LowerBoundary(), UpperBoundary()) | 25 @test boundary_identifiers(unitinterval()) == (LowerBoundary(), UpperBoundary()) |
26 | |
27 @test 0 ∈ Interval(0,1) | |
28 @test 0. ∈ Interval(0,1) | |
29 @test 1. ∈ Interval(0,1) | |
30 @test 2 ∉ Interval(0,1) | |
31 @test -1 ∉ Interval(0,1) | |
32 @test -1. ∉ Interval(0,1) | |
25 end | 33 end |
26 | 34 |
27 @testset "HyperBox" begin | 35 @testset "HyperBox" begin |
28 @test HyperBox{<:Any, 2} <: ParameterSpace{2} | 36 @test HyperBox{<:Any, 2} <: ParameterSpace{2} |
29 @test HyperBox([1,1], [2,2]) isa HyperBox{Int, 2} | 37 @test HyperBox([1,1], [2,2]) isa HyperBox{Int, 2} |
57 CartesianBoundary{2,LowerBoundary}(), | 65 CartesianBoundary{2,LowerBoundary}(), |
58 CartesianBoundary{2,UpperBoundary}(), | 66 CartesianBoundary{2,UpperBoundary}(), |
59 CartesianBoundary{3,LowerBoundary}(), | 67 CartesianBoundary{3,LowerBoundary}(), |
60 CartesianBoundary{3,UpperBoundary}(), | 68 CartesianBoundary{3,UpperBoundary}(), |
61 ] | 69 ] |
70 | |
71 @test @SVector[1.5, 3.5] ∈ HyperBox([1,2], [3,4]) | |
72 @test @SVector[1, 2] ∈ HyperBox([1,2], [3,4]) | |
73 @test @SVector[3, 4] ∈ HyperBox([1,2], [3,4]) | |
74 | |
75 @test @SVector[0.5, 3.5] ∉ HyperBox([1,2], [3,4]) | |
76 @test @SVector[1.5, 4.5] ∉ HyperBox([1,2], [3,4]) | |
62 end | 77 end |
63 | 78 |
64 @testset "Simplex" begin | 79 @testset "Simplex" begin |
65 @test Simplex{<:Any, 3} <: ParameterSpace{3} | 80 @test Simplex{<:Any, 3} <: ParameterSpace{3} |
66 @test Simplex([1,2], [3,4]) isa Simplex{Int, 2} | 81 @test Simplex([1,2], [3,4]) isa Simplex{Int, 2} |
75 | 90 |
76 @test unittetrahedron() isa Simplex{Float64,3} | 91 @test unittetrahedron() isa Simplex{Float64,3} |
77 @test verticies(unittetrahedron()) == ([0,0,0], [1,0,0], [0,1,0],[0,0,1]) | 92 @test verticies(unittetrahedron()) == ([0,0,0], [1,0,0], [0,1,0],[0,0,1]) |
78 | 93 |
79 @test unitsimplex(4) isa Simplex{Float64,4} | 94 @test unitsimplex(4) isa Simplex{Float64,4} |
95 | |
96 @testset "Base.in" begin | |
97 @testset "2D" begin | |
98 T₂ = Simplex([0.0, 0.0], [1.0, 0.0], [0.0, 1.0]) | |
99 @test [0.1, 0.1] ∈ T₂ | |
100 @test [0.3, 0.3] ∈ T₂ | |
101 @test [1.0, 0.0] ∈ T₂ | |
102 @test [0.0, 0.0] ∈ T₂ | |
103 @test [0.0, 1.0] ∈ T₂ | |
104 @test [0.5, 0.5] ∈ T₂ | |
105 | |
106 @test [0.6, 0.6] ∉ T₂ | |
107 @test [-0.1, 0.1] ∉ T₂ | |
108 end | |
109 | |
110 @testset "3D" begin | |
111 T₃ = Simplex([0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]) | |
112 @test [0.1, 0.1, 0.1] ∈ T₃ | |
113 @test [0.0, 0.0, 0.0] ∈ T₃ | |
114 @test [1.0, 0.0, 0.0] ∈ T₃ | |
115 @test [0.25, 0.25, 0.25] ∈ T₃ | |
116 @test [0.5, 0.5, 0.0] ∈ T₃ | |
117 @test [0.3, 0.3, 0.3] ∈ T₃ | |
118 | |
119 @test [0.5, 0.5, 1.0] ∉ T₃ | |
120 @test [0.3, 0.3, 0.5] ∉ T₃ | |
121 end | |
122 end | |
80 end | 123 end |