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

[ENHANCEMENT] Slicing operations like a["i" => 1, "j" => 1:2] = randn(2) are broken #27

Open
mtfishman opened this issue Jan 18, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@mtfishman
Copy link
Member

For example:

julia> using NamedDimsArrays

julia> a = nameddims(randn(2, 2), ("i", "j"))
named(2, named(Base.OneTo(2), "i"))×named(2, named(Base.OneTo(2), "j")) NamedDimsArray{Float64, 2, Matrix{Float64}, Tuple{NamedDimsArrays.NamedUnitRange{Int64, Base.OneTo{Int64}, String}, NamedDimsArrays.NamedUnitRange{Int64, Base.OneTo{Int64}, String}}} with indices named(Base.OneTo(2), named(Base.OneTo(2), "i"))×named(Base.OneTo(2), named(Base.OneTo(2), "j"))
2×2 Matrix{Float64}:
 0.754816  -0.227494
 0.150338   0.337033

julia> a["i" => 1, "j" => 1:2] = randn(2)
ERROR: MethodError: no method matching getindex(::Tuple{NamedDimsArrays.NamedUnitRange{Int64, Base.OneTo{…}, NamedDimsArrays.NamedUnitRange{…}}}, ::Nothing)
The function `getindex` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  getindex(::Tuple, ::CartesianIndex{1})
   @ Base multidimensional.jl:908
  getindex(::Tuple, ::Int64)
   @ Base tuple.jl:31
  getindex(::Tuple, ::Colon)
   @ Base tuple.jl:36
  ...

Stacktrace:
  [1] (::NamedDimsArrays.var"#57#58"{Tuple{NamedDimsArrays.NamedUnitRange{Int64, Base.OneTo{}, NamedDimsArrays.NamedUnitRange{}}}})(i::Nothing)
    @ NamedDimsArrays ~/.julia/dev/NamedDimsArrays/src/abstractnameddimsarray.jl:818
  [2] map
    @ ./tuple.jl:355 [inlined]
  [3] set_check_broadcast_shape(ax1::Tuple{NamedDimsArrays.NamedUnitRange{…}}, ax2::Tuple{NamedDimsArrays.NamedUnitRange{…}})
    @ NamedDimsArrays ~/.julia/dev/NamedDimsArrays/src/abstractnameddimsarray.jl:818
  [4] check_broadcast_shape(ax1::NamedDimsArrays.NaiveOrderedSet{Tuple{NamedDimsArrays.NamedUnitRange{…}}}, ax2::NamedDimsArrays.NaiveOrderedSet{Tuple{NamedDimsArrays.NamedUnitRange{…}}})
    @ NamedDimsArrays ~/.julia/dev/NamedDimsArrays/src/abstractnameddimsarray.jl:810
  [5] check_broadcast_axes
    @ ./broadcast.jl:550 [inlined]
  [6] instantiate
    @ ./broadcast.jl:305 [inlined]
  [7] materialize!(::NamedDimsArrays.NamedDimsArrayStyle{…}, dest::NamedDimsArray{…}, bc::Base.Broadcast.Broadcasted{…})
    @ Base.Broadcast ./broadcast.jl:878
  [8] materialize!
    @ ./broadcast.jl:875 [inlined]
  [9] setindex!(a::NamedDimsArray{…}, value::NamedDimsArray{…}, I1::NamedDimsArrays.NamedInteger{…}, Irest::NamedDimsArrays.NamedUnitRange{…})
    @ NamedDimsArrays ~/.julia/dev/NamedDimsArrays/src/abstractnameddimsarray.jl:571
 [10] setindex!(a::NamedDimsArray{…}, value::Vector{…}, I1::NamedDimsArrays.NamedInteger{…}, Irest::NamedDimsArrays.NamedUnitRange{…})
    @ NamedDimsArrays ~/.julia/dev/NamedDimsArrays/src/abstractnameddimsarray.jl:581
 [11] setindex!(a::NamedDimsArray{Float64, 2, Matrix{…}, Tuple{…}}, value::Vector{Float64}, I1::Pair{String, Int64}, Irest::Pair{String, UnitRange{…}})
    @ NamedDimsArrays ~/.julia/dev/NamedDimsArrays/src/abstractnameddimsarray.jl:464
 [12] top-level scope
    @ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types.
@mtfishman mtfishman added the enhancement New feature or request label Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant