Mercurial > repos > public > sbplib_julia
changeset 1289:3b7ebd135918 refactor/grids
Remove _component_type and replace with eltype
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 03 Mar 2023 15:44:39 +0100 |
parents | 7de1df0aad6a |
children | 31d0b7638304 |
files | src/Grids/grid.jl src/Grids/tensor_grid.jl test/Grids/grid_test.jl |
diffstat | 3 files changed, 1 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
diff -r 7de1df0aad6a -r 3b7ebd135918 src/Grids/grid.jl --- a/src/Grids/grid.jl Fri Mar 03 15:42:05 2023 +0100 +++ b/src/Grids/grid.jl Fri Mar 03 15:44:39 2023 +0100 @@ -63,6 +63,3 @@ # TODO: Explain how and where these are intended to be used _ncomponents(::Type{<:Number}) = 1 _ncomponents(T::Type{<:SVector}) = length(T) - -_component_type(T::Type{<:Number}) = T -_component_type(T::Type{<:SVector}) = eltype(T)
diff -r 7de1df0aad6a -r 3b7ebd135918 src/Grids/tensor_grid.jl --- a/src/Grids/tensor_grid.jl Fri Mar 03 15:42:05 2023 +0100 +++ b/src/Grids/tensor_grid.jl Fri Mar 03 15:44:39 2023 +0100 @@ -79,7 +79,7 @@ function combined_coordinate_vector_type(coordinate_types...) combined_coord_length = mapreduce(_ncomponents, +, coordinate_types) - combined_coord_type = mapreduce(_component_type, promote_type, coordinate_types) + combined_coord_type = mapreduce(eltype, promote_type, coordinate_types) if combined_coord_length == 1 return combined_coord_type
diff -r 7de1df0aad6a -r 3b7ebd135918 test/Grids/grid_test.jl --- a/test/Grids/grid_test.jl Fri Mar 03 15:42:05 2023 +0100 +++ b/test/Grids/grid_test.jl Fri Mar 03 15:44:39 2023 +0100 @@ -63,13 +63,3 @@ @test Grids._ncomponents(SVector{2,Float64}) == 2 @test Grids._ncomponents(SVector{4,Rational}) == 4 end - -@testset "_component_type" begin - @test Grids._component_type(Int) == Int - @test Grids._component_type(Float64) == Float64 - @test Grids._component_type(Rational) == Rational - - @test Grids._component_type(SVector{3,Int}) == Int - @test Grids._component_type(SVector{2,Float64}) == Float64 - @test Grids._component_type(SVector{4,Rational}) == Rational -end