You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would be useful if we had a formally defined to_dimension method that did something like:
@propagate_inboundsfunctionto_dimension(A::AbstractArray{T,N}, d::Integer) where {T,N}
@boundscheckif d <1error("BoundsError: attempt to access $(typeof(A)) at dimension $d")
endreturnInt(d)
end@propagate_inboundsfunctionto_dimension(A::AbstractArray{T,N}, dims::Tuple{Vararg{<:Integer,L}}) where {T,N,L}
returnntuple(i ->to_dimension(A, getfield(dims, i)), Val(L))
end
This would provide more useful error messages and provide another useful hook into the array interface. For example, methods that have a dimension argument could easily be made type stable with the following:
@propagate_inboundsfunctionto_dimension(A::AbstractArray, ::Val{D}) where {D}
returnto_dimension(A::AbstractArray, D)
end#functiondropdims(A; dims)
d =to_dimension(A, dims)
....end
The text was updated successfully, but these errors were encountered:
I think it would be useful if we had a formally defined
to_dimension
method that did something like:This would provide more useful error messages and provide another useful hook into the array interface. For example, methods that have a dimension argument could easily be made type stable with the following:
The text was updated successfully, but these errors were encountered: