comparison test/Grids/parameter_space_test.jl @ 1992:ca6d898d3a38 feature/grids/parameter_spaces/in

Implement Base.in(x, ::Simplex)
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 24 Apr 2025 09:23:12 +0200
parents 8cf1764ba124
children e6dbd4bec6cc
comparison
equal deleted inserted replaced
1991:7ead7a87af18 1992:ca6d898d3a38
90 90
91 @test unittetrahedron() isa Simplex{Float64,3} 91 @test unittetrahedron() isa Simplex{Float64,3}
92 @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])
93 93
94 @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 tetrahedron = 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] ∈ tetrahedron
113 @test [0.0, 0.0, 0.0] ∈ tetrahedron
114 @test [1.0, 0.0, 0.0] ∈ tetrahedron
115 @test [0.25, 0.25, 0.25] ∈ tetrahedron
116 @test [0.5, 0.5, 0.0] ∈ tetrahedron
117 @test [0.3, 0.3, 0.3] ∈ tetrahedron
118
119 @test [0.5, 0.5, 1.0] ∉ tetrahedron
120 @test [0.3, 0.3, 0.5] ∉ tetrahedron
121 end
122 end
95 end 123 end