Mercurial > repos > public > sbplib_julia
changeset 1943:48c49c04f3b2 feature/grids/manifolds
Merge feature/grids/parameter_spaces
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 07 Feb 2025 15:29:40 +0100 |
parents | b8395f69ad80 (current diff) 15be190a40cd (diff) |
children | 2a923e673cfc |
files | |
diffstat | 2 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/parameter_space.jl Fri Feb 07 14:05:37 2025 +0100 +++ b/src/Grids/parameter_space.jl Fri Feb 07 15:29:40 2025 +0100 @@ -45,6 +45,8 @@ """ limits(i::Interval) = (i.a, i.b) +boundary_identifiers(::Interval) = (LowerBoundary(), UpperBoundary()) + """ unitinterval(T=Float64) @@ -91,6 +93,16 @@ """ limits(box::HyperBox) = (box.a, box.b) +function boundary_identifiers(box::HyperBox) + mapreduce(vcat, 1:ndims(box)) do d + [ + CartesianBoundary{d, LowerBoundary}(), + CartesianBoundary{d, UpperBoundary}(), + ] + end +end + + """ unitsquare(T=Float64)
--- a/test/Grids/parameter_space_test.jl Fri Feb 07 14:05:37 2025 +0100 +++ b/test/Grids/parameter_space_test.jl Fri Feb 07 15:29:40 2025 +0100 @@ -1,5 +1,7 @@ using Test +using Diffinitive.Grids + @testset "ParameterSpace" begin @test ndims(HyperBox([1,1], [2,2])) == 2 @test ndims(unittetrahedron()) == 3 @@ -18,6 +20,8 @@ @test unitinterval(Int) isa Interval{Int} @test unitinterval(Int) == Interval(0,1) @test limits(unitinterval(Int)) == (0,1) + + @test boundary_identifiers(unitinterval()) == (LowerBoundary(), UpperBoundary()) end @testset "HyperBox" begin @@ -38,6 +42,23 @@ @test unithyperbox(4) isa HyperBox{Float64,4} @test limits(unithyperbox(4)) == ([0,0,0,0],[1,1,1,1]) + + + @test boundary_identifiers(unitsquare()) == [ + CartesianBoundary{1,LowerBoundary}(), + CartesianBoundary{1,UpperBoundary}(), + CartesianBoundary{2,LowerBoundary}(), + CartesianBoundary{2,UpperBoundary}(), + ] + + @test boundary_identifiers(unitcube()) == [ + CartesianBoundary{1,LowerBoundary}(), + CartesianBoundary{1,UpperBoundary}(), + CartesianBoundary{2,LowerBoundary}(), + CartesianBoundary{2,UpperBoundary}(), + CartesianBoundary{3,LowerBoundary}(), + CartesianBoundary{3,UpperBoundary}(), + ] end @testset "Simplex" begin