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 DimensionMismatch for SparseMatrixCSC assignment #28963

Closed
fgerick opened this issue Aug 30, 2018 · 1 comment
Closed

Missing DimensionMismatch for SparseMatrixCSC assignment #28963

fgerick opened this issue Aug 30, 2018 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays

Comments

@fgerick
Copy link

fgerick commented Aug 30, 2018

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
@fgerick
Copy link
Author

fgerick commented Aug 30, 2018

Also causes segmentation faults in some cases if the dimensions mismatch.

@KristofferC KristofferC added bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays labels Aug 31, 2018
@fgerick fgerick changed the title Missing DimensionMismatch for SparseMatrixCSC assignment in 0.7 Missing DimensionMismatch for SparseMatrixCSC assignment Dec 18, 2018
@ViralBShah ViralBShah assigned mbauman and unassigned mbauman Dec 25, 2018
ViralBShah pushed a commit that referenced this issue Dec 26, 2018
Use _setindex! to fix DimensionMismatch in sparse assignment
Fixes #28963
staticfloat pushed a commit that referenced this issue Dec 30, 2018
Use _setindex! to fix DimensionMismatch in sparse assignment
Fixes #28963
KristofferC pushed a commit that referenced this issue Dec 30, 2018
Use _setindex! to fix DimensionMismatch in sparse assignment
Fixes #28963

(cherry picked from commit b73a746)
@KristofferC KristofferC mentioned this issue Dec 30, 2018
53 tasks
staticfloat pushed a commit that referenced this issue Jan 4, 2019
Use _setindex! to fix DimensionMismatch in sparse assignment
Fixes #28963
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

3 participants