JuliaSparse / SuiteSparseGraphBLAS.jl

Sparse, General Linear Algebra for Graphs!
MIT License
102 stars 17 forks source link

problems in reshaping full GBMatrix into vector #106

Closed CarloLucibello closed 1 year ago

CarloLucibello commented 1 year ago
julia> a = rand(2, 4) |> GBMatrix
2x4 GraphBLAS double matrix, full by col
  8 entries, memory: 272 bytes

    (1,1)    0.376955
    (2,1)    0.704176
    (1,2)    0.490282
    (2,2)    0.746083
    (1,3)    0.231588
    (2,3)    0.0124536
    (1,4)    0.914377
    (2,4)    0.124544

julia> reshape(a, :) # the result should be a vector, not a matrix
8x1 GraphBLAS double matrix, full by col
  8 entries, memory: 272 bytes

    (1,1)    0.376955
    (2,1)    0.704176
    (3,1)    0.490282
    (4,1)    0.746083
    (5,1)    0.231588
    (6,1)    0.0124536
    (7,1)    0.914377
    (8,1)    0.124544

julia> reshape(a, :) isa AbstractVector # this should give true
false

julia> reshape(a, 8)  # this should be equivalent to reshape(a, :)
ERROR: MethodError: reshape(::GBMatrix{Float64, Float64}, ::Int64) is ambiguous. Candidates:
  reshape(parent::AbstractArray, dims::Int64...) in Base at reshapedarray.jl:117
  reshape(parent::AbstractArray, dims::Union{Int64, AbstractUnitRange}...) in Base at reshapedarray.jl:110
  reshape(A::SuiteSparseGraphBLAS.AbstractGBArray{T, F, O, 2} where {T, F, O}, n::Union{Colon, Int64}; bycol) in SuiteSparseGraphBLAS at /Users/carlo/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/abstractgbarray.jl:240
Possible fix, define
  reshape(::SuiteSparseGraphBLAS.AbstractGBArray{T, F, O, 2} where {T, F, O}, ::Int64)
Stacktrace:
 [1] top-level scope
   @ REPL[147]:1
rayegun commented 1 year ago

This was fixed at some point, not sure when but is working on master.