Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strides missing methods for various AbstractArray subtypes #29705

Closed
musm opened this issue Oct 18, 2018 · 4 comments · May be fixed by #30432
Closed

strides missing methods for various AbstractArray subtypes #29705

musm opened this issue Oct 18, 2018 · 4 comments · May be fixed by #30432
Labels
arrays [a, r, r, a, y, s]

Comments

@musm
Copy link
Contributor

musm commented Oct 18, 2018

Seems like some simple methods are missing for strides function

julia> strides(randn(5,5)')
ERROR: MethodError: no method matching strides(::LinearAlgebra.Adjoint{Float64,Array{Float64,2}})

similarily

julia> strides(transpose(randn(5,5))

and also other basic subtypes of AbstractArray such as Diagonal etc.

@korbinian90
Copy link

korbinian90 commented May 4, 2020

Is this still worked on? No method is available for BitArrays in Julia 1.4.1

julia> strides([1,0] .> 0)
ERROR: MethodError: no method matching strides(::BitArray{1})

Also NIVolume, the AbstractArray subtype from NIfTI.jl doesn't work with strides.
I defined a simple helper method for my project, as size is defined for all abstract arrays:

Base.strides(A::AbstractArray) = (1, cumprod(collect(size(A)))[1:end-1]...)

@mbauman
Copy link
Member

mbauman commented May 4, 2020

In Julia, we've used the stride terminology to talk about storage locations. BitArrays don't have strided storage locations, so they'll never support strides.

@korbinian90
Copy link

Thanks for your answer!
As I was looking for a different concept, I should name my function something like linear_neighbor_offsets.
And probably I should try to use the 'safe' way with LinearIndices.

@mbauman
Copy link
Member

mbauman commented May 4, 2020

This particular example is now fixed in #29135. I think we can roll the rest into the bigger #30432.

@mbauman mbauman closed this as completed May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants