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

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

Open
ogauthe opened this issue Dec 10, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@ogauthe
Copy link
Contributor

ogauthe commented Dec 10, 2024

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

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

g = gradedrange([TrivialSector()=>2])
bsa = BlockSparseArray{Float64}(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.

@ogauthe ogauthe added the bug Something isn't working label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant