Skip to content

Commit

Permalink
Replace set_ndims across the library with an AbstractArray version
Browse files Browse the repository at this point in the history
  • Loading branch information
kmp5VT committed Mar 15, 2024
1 parent 78233a0 commit 2c0b28f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ function set_eltype(array::AbstractArray, param)
return convert(set_eltype(typeof(array), param), array)
end

## This will fail if position of `ndims` is not defined for `type`
function set_ndims(type::Type{<:AbstractArray}, param)
return error("Not implemented")
return set_type_parameter(type, Base.ndims, param)
end

using SimpleTraits: SimpleTraits, @traitdef, @traitimpl
Expand Down Expand Up @@ -70,7 +71,7 @@ end
for wrapper in [:PermutedDimsArray, :(Base.ReshapedArray), :SubArray]
@eval begin
position(type::Type{<:$wrapper}, ::typeof(eltype)) = Position(1)
position(type::Type{<:$wrapper}, ::typeof(ndims)) = Position(2)
position(type::Type{<:$wrapper}, ::typeof(Base.ndims)) = Position(2)
end
end
for wrapper in [:(Base.ReshapedArray), :SubArray]
Expand Down

0 comments on commit 2c0b28f

Please sign in to comment.