changeset 1438:66ad232e45a1 refactor/grids/tensor_grid_eltype

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 22 Nov 2023 17:47:32 +0100
parents 25af92b4a7ea (diff) e3a80ef08d09 (current diff)
children 371c7a1aa66f
files src/Grids/tensor_grid.jl test/Grids/tensor_grid_test.jl
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/Grids/tensor_grid.jl	Wed Nov 22 17:34:35 2023 +0100
+++ b/src/Grids/tensor_grid.jl	Wed Nov 22 17:47:32 2023 +0100
@@ -43,7 +43,6 @@
 _iterate_combine_coords((next,state)) = combine_coordinates(next...), state
 
 Base.IteratorSize(::Type{<:TensorGrid{<:Any, D}}) where D = Base.HasShape{D}()
-Base.eltype(::Type{<:TensorGrid{T}}) where T = T
 Base.length(g::TensorGrid) = sum(length, g.grids)
 Base.size(g::TensorGrid) = LazyTensors.concatenate_tuples(size.(g.grids)...)
 Base.size(g::TensorGrid, d) = size(g)[d]
--- a/test/Grids/tensor_grid_test.jl	Wed Nov 22 17:34:35 2023 +0100
+++ b/test/Grids/tensor_grid_test.jl	Wed Nov 22 17:47:32 2023 +0100
@@ -85,6 +85,12 @@
         @test eltype(TensorGrid(g₁, g₄)) == SVector{3,Float64}
         @test eltype(TensorGrid(g₁, g₄, g₂)) == SVector{4,Float64}
 
+        @test eltype(typeof(TensorGrid(g₁, g₂))) == SVector{2,Float64}
+        @test eltype(typeof(TensorGrid(g₁, g₃))) == SVector{2,Float64}
+        @test eltype(typeof(TensorGrid(g₁, g₂, g₃))) == SVector{3,Float64}
+        @test eltype(typeof(TensorGrid(g₁, g₄))) == SVector{3,Float64}
+        @test eltype(typeof(TensorGrid(g₁, g₄, g₂))) == SVector{4,Float64}
+
         @test size(TensorGrid(g₁, g₂)) == (11,6)
         @test size(TensorGrid(g₁, g₃)) == (11,10)
         @test size(TensorGrid(g₁, g₂, g₃)) == (11,6,10)