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

missing similar method for PseudoBlockArray (mapslices unusable) #226

Open
yha opened this issue Oct 11, 2022 · 4 comments
Open

missing similar method for PseudoBlockArray (mapslices unusable) #226

yha opened this issue Oct 11, 2022 · 4 comments

Comments

@yha
Copy link

yha commented Oct 11, 2022

julia> using BlockArrays

julia> b = mortar([rand(5,5) for i=1:2, j=1:2]);

julia> mapslices(identity, b[1:5,:]; dims=1)
ERROR: MethodError: no method matching similar(::Vector{Float64}, ::Type{Float64}, ::Tuple{UnitRange{Int64}, UnitRange{Int64}})
Closest candidates are:
  similar(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{N}}, ::Type{ElType}, ::Any) where {N, ElType} at C:\Users\sternlab\AppData\Local\Programs\Julia-1.7.2\share\julia\base\broadcast.jl:212
  similar(::Base.Broadcast.Broadcasted{Base.Broadcast.ArrayConflict}, ::Type{ElType}, ::Any) where ElType at C:\Users\sternlab\AppData\Local\Programs\Julia-1.7.2\share\julia\base\broadcast.jl:217
  similar(::ArrayLayouts.MulAdd{<:Any, <:ArrayLayouts.DualLayout, ArrayLayouts.ZerosLayout}, ::Type{T}, ::Any) where T at C:\Users\sternlab\.julia\packages\ArrayLayouts\nCtQC\src\muladd.jl:414
  ...
Stacktrace:
 [1] similar(a::Vector{Float64}, dims::Tuple{UnitRange{Int64}, UnitRange{Int64}})
   @ Base .\abstractarray.jl:783
 [2] mapslices(f::typeof(identity), A::PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{Base.OneTo{Int64}, BlockedUnitRange{Vector{Int64}}}}; dims::Int64)
   @ Base .\abstractarray.jl:2795
 [3] top-level scope
   @ REPL[5]:1

This is a regression introduced between 0.16.17 and 0.16.18

@jishnub
Copy link
Member

jishnub commented Jul 20, 2023

This appears to work now:

julia> mapslices(identity, b[1:5,:]; dims=1)
1×2-blocked 5×10 PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{Base.OneTo{Int64}, BlockedUnitRange{Vector{Int64}}}}:
 0.89626   0.274113    0.703425   0.579062  0.9891650.372363  0.659855   0.689075  0.0578565   0.688581 
 0.278924  0.147276    0.791482   0.133684  0.02796320.693008  0.0273849  0.594499  0.713912    0.2946   
 0.865734  0.00203172  0.184889   0.758688  0.94950.271894  0.44169    0.467267  0.501292    0.692319 
 0.866907  0.894063    0.0381348  0.272919  0.9268280.248664  0.798704   0.807312  0.520421    0.859454 
 0.615061  0.603609    0.564914   0.263001  0.4232670.402052  0.452154   0.571618  0.00275745  0.0255126

@jishnub jishnub closed this as completed Jul 20, 2023
@yha
Copy link
Author

yha commented Jul 20, 2023

It works in julia 1.6 and 1.9, but not in 1.7 or 1.8.
Are these versions still meant to be supported?

@jishnub jishnub reopened this Jul 20, 2023
@jishnub
Copy link
Member

jishnub commented Jul 20, 2023

Ah ok, worth looking into it then, as these versions are supported. Wonder what changed in v1.9 that makes this work?

@yha
Copy link
Author

yha commented Jul 20, 2023

Seems to be this: JuliaLang/julia#40996
Stack trace on julia 1.8.5 points to this line:
https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/abstractarray.jl#L2875C38-L2875C38
which was eliminated in that PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants