Skip to content

Vector{Int} indexing of NamedArrayPartition broken for v4+ #583

@jlchan

Description

@jlchan

Describe the example

Indexing into a NamedArrayPartition with Vector{Int} does not work after the v4 update. This seems to be due to 05faa73

Minimal Reproducible Example 👇

using RecursiveArrayTools
x = NamedArrayPartition(a = ones(2), b = 2 * ones(3))
x[1:2] # fails with v4+

However, the above works for x = NamedArrayPartition(a = ones(1), b = 2 * ones(1)).

Error & Stacktrace ⚠️

julia> x[1:2] # fails with v4+
ERROR: MethodError: no method matching NamedArrayPartition(::Vector{Float64}, ::@NamedTuple{a::Int64, b::Int64})
The type `NamedArrayPartition` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  NamedArrayPartition(::A, ::NT) where {T, A<:(ArrayPartition{T}), NT<:NamedTuple}
   @ RecursiveArrayTools ~/.julia/packages/RecursiveArrayTools/GM23x/src/named_array_partition.jl:10
  NamedArrayPartition(::F, ::Any, ::Any) where F<:Function
   @ RecursiveArrayTools ~/.julia/packages/RecursiveArrayTools/GM23x/src/named_array_partition.jl:144
  NamedArrayPartition(; kwargs...)
   @ RecursiveArrayTools ~/.julia/packages/RecursiveArrayTools/GM23x/src/named_array_partition.jl:13
  ...

Stacktrace:
 [1] similar(A::NamedArrayPartition{Float64, ArrayPartition{…}, @NamedTuple{…}}, ::Type{Float64}, dims::Tuple{Int64})
   @ RecursiveArrayTools ~/.julia/packages/RecursiveArrayTools/GM23x/src/named_array_partition.jl:53
 [2] similar
   @ ./abstractarray.jl:822 [inlined]
 [3] _unsafe_getindex(::IndexCartesian, A::NamedArrayPartition{…}, I::UnitRange{…})
   @ Base ./multidimensional.jl:968
 [4] _getindex
   @ ./multidimensional.jl:956 [inlined]
 [5] getindex(A::NamedArrayPartition{Float64, ArrayPartition{…}, @NamedTuple{…}}, I::UnitRange{Int64})
   @ Base ./abstractarray.jl:1342
 [6] top-level scope
   @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

Not Working Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
julia> using Pkg; Pkg.status()
Status `/private/var/folders/rq/3s_b2f257xs0blrhx7tx1xkc0000gq/T/jl_8EQxJI/Project.toml`
  [731186ca] RecursiveArrayTools v4.2.0
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
julia> using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Status `/private/var/folders/rq/3s_b2f257xs0blrhx7tx1xkc0000gq/T/jl_8EQxJI/Manifest.toml`
  [7d9f7c33] Accessors v0.1.44
  [79e6a3ab] Adapt v4.5.2
  [4fba245c] ArrayInterface v7.24.0
  [a33af91c] CompositionsBase v0.1.2
  [187b0558] ConstructionBase v1.6.0
  [ffbed154] DocStringExtensions v0.9.5
  [e2ba6199] ExprTools v0.1.10
  [46192b85] GPUArraysCore v0.2.0
  [3587e190] InverseFunctions v0.1.17
  [1914dd2f] MacroTools v0.5.16
  [aea7be01] PrecompileTools v1.3.3
  [21216c6a] Preferences v1.5.2
  [3cdcf5f2] RecipesBase v1.3.4
  [731186ca] RecursiveArrayTools v4.2.0
  [ae029012] Requires v1.3.1
  [7e49a35a] RuntimeGeneratedFunctions v0.5.18
  [1e83bf80] StaticArraysCore v1.4.4
  [2efcf032] SymbolicIndexingInterface v0.3.46
  [56f22d72] Artifacts v1.11.0
  [ade2ca70] Dates v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.12.0
  [de0858da] Printf v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization v1.11.0
  [fa267f1f] TOML v1.0.3
  [cf7118a7] UUIDs v1.11.0
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.3.0+1
  [4536629a] OpenBLAS_jll v0.3.29+0
  [8e850b90] libblastrampoline_jll v5.15.0+0
  • Output of versioninfo()
julia> versioninfo()
Julia Version 1.12.2
Commit ca9b6662be4 (2025-11-20 16:25 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 16 × Apple M4 Max
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, apple-m4)
  GC: Built with stock GC
Threads: 12 default, 1 interactive, 12 GC (on 12 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_VSCODE_REPL = 1
  JULIA_NUM_THREADS = 12

Working Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
julia> using Pkg; Pkg.status()
Status `/private/var/folders/rq/3s_b2f257xs0blrhx7tx1xkc0000gq/T/jl_EtaLDd/Project.toml`
⌃ [731186ca] RecursiveArrayTools v3.8.1
Info Packages marked with ⌃ have new versions available and may be upgradable.
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
julia> using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Status `/private/var/folders/rq/3s_b2f257xs0blrhx7tx1xkc0000gq/T/jl_EtaLDd/Manifest.toml`
  [7d9f7c33] Accessors v0.1.44
  [79e6a3ab] Adapt v4.5.2
  [4fba245c] ArrayInterface v7.24.0
  [a33af91c] CompositionsBase v0.1.2
  [187b0558] ConstructionBase v1.6.0
  [9a962f9c] DataAPI v1.16.0
  [e2d170a0] DataValueInterfaces v1.0.0
  [ffbed154] DocStringExtensions v0.9.5
  [e2ba6199] ExprTools v0.1.10
⌅ [46192b85] GPUArraysCore v0.1.6
  [3587e190] InverseFunctions v0.1.17
  [82899510] IteratorInterfaceExtensions v1.0.0
  [1914dd2f] MacroTools v0.5.16
  [bac558e1] OrderedCollections v1.8.1
  [aea7be01] PrecompileTools v1.3.3
  [21216c6a] Preferences v1.5.2
  [3cdcf5f2] RecipesBase v1.3.4
⌃ [731186ca] RecursiveArrayTools v3.8.1
  [ae029012] Requires v1.3.1
  [7e49a35a] RuntimeGeneratedFunctions v0.5.18
  [1e83bf80] StaticArraysCore v1.4.4
  [10745b16] Statistics v1.11.1
  [2efcf032] SymbolicIndexingInterface v0.3.46
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.12.1
  [56f22d72] Artifacts v1.11.0
  [ade2ca70] Dates v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.12.0
  [de0858da] Printf v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization v1.11.0
  [2f01184e] SparseArrays v1.12.0
  [fa267f1f] TOML v1.0.3
  [cf7118a7] UUIDs v1.11.0
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.3.0+1
  [4536629a] OpenBLAS_jll v0.3.29+0
  [bea87d4a] SuiteSparse_jll v7.8.3+2
  [8e850b90] libblastrampoline_jll v5.15.0+0
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`
  • Output of versioninfo()
julia> versioninfo()
Julia Version 1.12.2
Commit ca9b6662be4 (2025-11-20 16:25 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 16 × Apple M4 Max
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, apple-m4)
  GC: Built with stock GC
Threads: 12 default, 1 interactive, 12 GC (on 12 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_VSCODE_REPL = 1
  JULIA_NUM_THREADS = 12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions