Mercurial > repos > public > sbplib_julia
changeset 1288:7de1df0aad6a refactor/grids
Add component_type function to Grid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 03 Mar 2023 15:42:05 +0100 |
parents | 014d365c18de |
children | 3b7ebd135918 |
files | src/Grids/Grids.jl src/Grids/grid.jl test/Grids/grid_test.jl |
diffstat | 3 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/Grids.jl Fri Mar 03 15:40:20 2023 +0100 +++ b/src/Grids/Grids.jl Fri Mar 03 15:42:05 2023 +0100 @@ -7,6 +7,7 @@ # Grid export Grid export target_manifold_dim +export component_type export dims export TensorGrid
--- a/src/Grids/grid.jl Fri Mar 03 15:40:20 2023 +0100 +++ b/src/Grids/grid.jl Fri Mar 03 15:42:05 2023 +0100 @@ -12,6 +12,7 @@ Base.ndims(::Grid{T,D}) where {T,D} = D Base.eltype(::Type{<:Grid{T}}) where T = T target_manifold_dim(::Grid{T}) where T = _ncomponents(T) # TBD: Name of this function?! +component_type(::Grid{T}) where T = eltype(T) """ # TODO
--- a/test/Grids/grid_test.jl Fri Mar 03 15:40:20 2023 +0100 +++ b/test/Grids/grid_test.jl Fri Mar 03 15:42:05 2023 +0100 @@ -14,6 +14,16 @@ @test target_manifold_dim(DummyGrid{Int, 1}()) == 1 @test target_manifold_dim(DummyGrid{SVector{3,Float64}, 2}()) == 3 + + @testset "component_type" begin + @test component_type(DummyGrid{Int,1}()) == Int + @test component_type(DummyGrid{Float64,1}()) == Float64 + @test component_type(DummyGrid{Rational,1}()) == Rational + + @test component_type(DummyGrid{SVector{3,Int},2}()) == Int + @test component_type(DummyGrid{SVector{2,Float64},3}()) == Float64 + @test component_type(DummyGrid{SVector{4,Rational},4}()) == Rational + end end @testset "eval_on" begin