Skip to content

SparseMatrixCSC() allows creating invalid matrices #14489

Closed

Description

Looks like the constructor should throw an error when trying to create invalid SparseMatrixCSC objects:

julia> x=SparseMatrixCSC(4, 4, Int[], Int[], Int[]);

julia> x
Error showing value of type SparseMatrixCSC{Int64,Int64}:
ERROR: BoundsError: attempt to access 0-element Array{Int64,1}
  at index [0]
 [inlined code] from sparse/sparsematrix.jl:34
 in showarray at sparse/sparsematrix.jl:85
 in anonymous at replutil.jl:38
 in with_output_limit at ./show.jl:1341
 [inlined code] from show.jl:1337
 in writemime at replutil.jl:37
 [inlined code] from expr.jl:8 (repeats 2 times)
 in display at REPL.jl:114
 [inlined code] from multimedia.jl:151
 in display at multimedia.jl:163
 in print_response at REPL.jl:134
 in print_response at REPL.jl:121
 in anonymous at REPL.jl:624
 in run_interface at ./LineEdit.jl:1610
 in run_frontend at ./REPL.jl:864
 in run_repl at ./REPL.jl:167
 in _start at ./client.jl:343

julia> x[1,1]
ERROR: BoundsError: attempt to access 0-element Array{Int64,1}
  at index [1]
 in getindex at sparse/sparsematrix.jl:1348
 in eval at ./boot.jl:265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    sparseSparse arrays

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions