Closed
Description
I've encountered a strange behaviour of assigning to a SparseMatrixCSC
in 0.7:
using SparseArrays
a=spzeros(10,10)
b=sprandn(10,20,0.5)
a[:,:]=b[:,:]
This does not give a DimensionMismatch
as it did in Julia v0.6, and I guess it should definitely give an error.
In 0.7 it just assignes the 1:10,1:10 elements of b to a:
b[1:10,1:10] ≈ a #true
The broadcasted assignment, however, gives an error:
a[:,:].=b[:,:]
ERROR: DimensionMismatch("array could not be broadcast to match destination")
Stacktrace:
[1] check_broadcast_shape at ./broadcast.jl:452 [inlined]
[2] check_broadcast_shape at ./broadcast.jl:453 [inlined]
[3] check_broadcast_axes at ./broadcast.jl:455 [inlined]
[4] instantiate at ./broadcast.jl:269 [inlined]
[5] materialize!(::SubArray{Float64,2,SparseMatrixCSC{Float64,Int64},Tuple{Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}}},false}, ::Base.Broadcast.Broadcasted{SparseArrays.HigherOrderFns.SparseMatStyle,Nothing,typeof(identity),Tuple{SparseMatrixCSC{Float64,Int64}}}) at ./broadcast.jl:727
[6] top-level scope at none:0
versioninfo()
Julia Version 0.7.0
Commit a4cb80f3ed (2018-08-08 06:46 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4