comparison src/Grids/grid.jl @ 2029:1fa47cacd3dd

Fix bug in IndexStyle for ArrayComponentView
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 28 Jan 2026 11:00:28 +0100
parents 76c6bde84656
children
comparison
equal deleted inserted replaced
2008:df2cbcb7a2b1 2029:1fa47cacd3dd
72 CT = typeof(first(v)[component_index...]) 72 CT = typeof(first(v)[component_index...])
73 return new{CT, eltype(v), ndims(v), typeof(v), typeof(component_index)}(v,component_index) 73 return new{CT, eltype(v), ndims(v), typeof(v), typeof(component_index)}(v,component_index)
74 end 74 end
75 end 75 end
76 76
77 _array_type(v::ArrayComponentView) = typeof(v)
78 _array_type(::Type{ArrayComponentView{CT,T,D,AT,IT}}) where {CT,T,D,AT,IT} = AT
79
77 Base.size(cv::ArrayComponentView) = size(cv.v) 80 Base.size(cv::ArrayComponentView) = size(cv.v)
78 Base.getindex(cv::ArrayComponentView, i::Int) = cv.v[i][cv.component_index...] 81 Base.getindex(cv::ArrayComponentView, i::Int) = cv.v[i][cv.component_index...]
79 Base.getindex(cv::ArrayComponentView, I::Vararg{Int}) = cv.v[I...][cv.component_index...] 82 Base.getindex(cv::ArrayComponentView, I::Vararg{Int}) = cv.v[I...][cv.component_index...]
80 IndexStyle(::Type{<:ArrayComponentView{<:Any,<:Any,AT}}) where AT = IndexStyle(AT) 83 IndexStyle(ACT::Type{ArrayComponentView}) = IndexStyle(_array_type(ACT))
81 84
82 # TODO: Implement `setindex!`? 85 # TODO: Implement `setindex!`?
83 # TODO: Implement a more general ComponentView that can handle non-AbstractArrays. 86 # TODO: Implement a more general ComponentView that can handle non-AbstractArrays.
84 87
85 88