diff src/Grids/tensor_grid.jl @ 1270:dcbac783e4c1 refactor/grids

Factor out functions for getting the type and number of components in a type
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 25 Feb 2023 22:42:16 +0100
parents a4ddae8b5d49
children 3b7ebd135918
line wrap: on
line diff
--- a/src/Grids/tensor_grid.jl	Sat Feb 25 22:22:50 2023 +0100
+++ b/src/Grids/tensor_grid.jl	Sat Feb 25 22:42:16 2023 +0100
@@ -78,15 +78,8 @@
 
 
 function combined_coordinate_vector_type(coordinate_types...)
-    coord_length(::Type{<:Number}) = 1
-    coord_length(T::Type{<:SVector}) = length(T)
-
-    coord_type(T::Type{<:Number}) = T
-    coord_type(T::Type{<:SVector}) = eltype(T)
-
-
-    combined_coord_length = mapreduce(coord_length, +, coordinate_types)
-    combined_coord_type = mapreduce(coord_type, promote_type, coordinate_types)
+    combined_coord_length = mapreduce(_ncomponents, +, coordinate_types)
+    combined_coord_type = mapreduce(_component_type, promote_type, coordinate_types)
 
     if combined_coord_length == 1
         return combined_coord_type