Skip to content

[BUG] setindex!(::BlockSparseArray, ::Array, ::BlockIndexRange) errors #12

@ogauthe

Description

@ogauthe

Issue: setindex!(::BlockSparseArray, ::BlockIndexRange) fails for any AbstractGradedUnitRange

g0 = blockedrange([2])
bsa0 = BlockSparseArray{Float64}(undef, g0, g0)
bsa0[Block(1,1)[1:2,1:2]] = ones((2,2))  # Ok

g = gradedrange([TrivialSector()=>2])
bsa = BlockSparseArray{Float64}(undef, g, g)
bsa[Block(1,1)] = ones((2,2))  # Ok
@show bsa[Block(1,1)[1:2,1:2]]  # Ok
bsa[Block(1,1)[1:2,1:2]] = zeros((2,2))  # MethodError
ERROR: MethodError: no method matching LabelledNumbers.LabelledInteger{Int64, TrivialSector}(::Int64)
The type `LabelledNumbers.LabelledInteger{Int64, TrivialSector}` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  (::Type{LabelledNumbers.LabelledInteger{Value, Label}} where {Value<:Integer, Label})(::Any, ::Any)
   @ LabelledNumbers ~/.julia/packages/LabelledNumbers/Pn1xf/src/labelledinteger.jl:2
  (::Type{T})(::T) where T<:Number
   @ Core boot.jl:900
  (::Type{T})(::BigFloat) where T<:Integer
   @ Base mpfr.jl:403
  ...

Stacktrace:
 [1] convert(::Type{LabelledNumbers.LabelledInteger{Int64, TrivialSector}}, x::Int64)
   @ Base ./number.jl:7
 [2] iterate
   @ ./range.jl:909 [inlined]
 [3] macro expansion
   @ ./cartesian.jl:66 [inlined]
 [4] _unsafe_setindex!
   @ ./multidimensional.jl:979 [inlined]
 [5] _setindex!
   @ ./multidimensional.jl:967 [inlined]
 [6] setindex!(A::BlockSparseArray{…}, v::Matrix{…}, I::BlockArrays.BlockIndexRange{…})
   @ Base ./abstractarray.jl:1413
 [7] top-level scope
   @ REPL[105]:1
Some type information was truncated. Use `show(err)` to see complete types.

The error is detected in BlockSparseArrays, however it looks pretty similar to previous issues with dual axes: the problem may be in GradedUnitRanges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions