Skip to content

Error in ArrayInterface.StrideIndex introduced between v6.0.11 and v6.0.12 #304

@ranocha

Description

@ranocha

I could reduce an error in the CI of Trixi.jl to the following MWE:

julia> using Pkg; Pkg.activate(temp=true); Pkg.add(name="ArrayInterface", version="6.0.12")
  Activating new project at `/tmp/jl_8oD6Fu`
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `/tmp/jl_8oD6Fu/Project.toml`
  [4fba245c] + ArrayInterface v6.0.12
    Updating `/tmp/jl_8oD6Fu/Manifest.toml`
  [4fba245c] + ArrayInterface v6.0.12
  [30b0a656] + ArrayInterfaceCore v0.1.10
  [34da2185] + Compat v4.1.0
  [615f187c] + IfElse v0.1.1
  [aedffcd0] + Static v0.6.6
  [56f22d72] + Artifacts
  [ade2ca70] + Dates
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [de0858da] + Printf
  [9a3f8284] + Random
  [ea8e919c] + SHA
  [9e88b42a] + Serialization
  [2f01184e] + SparseArrays
  [4607b0f0] + SuiteSparse
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
  [e66e0078] + CompilerSupportLibraries_jll
  [4536629a] + OpenBLAS_jll
  [8e850b90] + libblastrampoline_jll

julia> using ArrayInterface

julia> begin
           n = 4
           u_plain = randn(1, n, n, 1)
           u_vectors = reshape(reinterpret(Tuple{eltype(u_plain)}, u_plain), n, n, 1)
           u_view = view(u_vectors, :, 1, 1)
           u_final = reshape(reinterpret(eltype(u_plain), u_view), 1, length(u_view))
       end
1×4 reshape(reinterpret(Float64, view(reshape(reinterpret(Tuple{Float64}, ::Array{Float64, 4}), 4, 4, 1), :, 1, 1)), 1, 4) with eltype Float64:
 1.07215  -0.243029  2.77844  0.476478

julia> ArrayInterface.StrideIndex(u_final)
ERROR: MethodError: no method matching -(::Nothing)
Closest candidates are:
  -(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) at ~/Software/julia-1.7.3/share/julia/base/int.jl:85
  -(::T, ::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at ~/Software/julia-1.7.3/share/julia/base/int.jl:86
  -(::Union{UInt16, UInt32, UInt64, UInt8}, ::BigInt) at ~/Software/julia-1.7.3/share/julia/base/gmp.jl:532
  ...
Stacktrace:
 [1] contiguous_axis(#unused#::Type{Base.ReshapedArray{Float64, 2, Base.ReinterpretArray{Float64, 1, Tuple{Float64}, SubArray{Tuple{Float64}, 1, Base.ReshapedArray{Tuple{Float64}, 3, Base.ReinterpretArray{Tuple{Float64}, 4, Float64, Array{Float64, 4}, false}, Tuple{}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64, Int64}, true}, false}, Tuple{}}})
   @ ArrayInterface ~/.julia/packages/ArrayInterface/sOwN6/src/stridelayout.jl:167
 [2] ArrayInterface.StrideIndex(a::Base.ReshapedArray{Float64, 2, Base.ReinterpretArray{Float64, 1, Tuple{Float64}, SubArray{Tuple{Float64}, 1, Base.ReshapedArray{Tuple{Float64}, 3, Base.ReinterpretArray{Tuple{Float64}, 4, Float64, Array{Float64, 4}, false}, Tuple{}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64, Int64}, true}, false}, Tuple{}})
   @ ArrayInterface ~/.julia/packages/ArrayInterface/sOwN6/src/array_index.jl:18
 [3] top-level scope
   @ REPL[4]:1

Everything is fine with ArrayInterfacev6.0.11:

julia> using Pkg; Pkg.activate(temp=true); Pkg.add(name="ArrayInterface", version="6.0.11")
  Activating new project at `/tmp/jl_JwIOdc`
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `/tmp/jl_JwIOdc/Project.toml`
  [4fba245c] + ArrayInterface v6.0.11
    Updating `/tmp/jl_JwIOdc/Manifest.toml`
  [4fba245c] + ArrayInterface v6.0.11
  [30b0a656] + ArrayInterfaceCore v0.1.10
  [34da2185] + Compat v4.1.0
  [615f187c] + IfElse v0.1.1
  [aedffcd0] + Static v0.6.6
  [56f22d72] + Artifacts
  [ade2ca70] + Dates
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [de0858da] + Printf
  [9a3f8284] + Random
  [ea8e919c] + SHA
  [9e88b42a] + Serialization
  [2f01184e] + SparseArrays
  [4607b0f0] + SuiteSparse
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
  [e66e0078] + CompilerSupportLibraries_jll
  [4536629a] + OpenBLAS_jll
  [8e850b90] + libblastrampoline_jll

julia> using ArrayInterface

julia> begin
           n = 4
           u_plain = randn(1, n, n, 1)
           u_vectors = reshape(reinterpret(Tuple{eltype(u_plain)}, u_plain), n, n, 1)
           u_view = view(u_vectors, :, 1, 1)
           u_final = reshape(reinterpret(eltype(u_plain), u_view), 1, length(u_view))
       end
1×4 reshape(reinterpret(Float64, view(reshape(reinterpret(Tuple{Float64}, ::Array{Float64, 4}), 4, 4, 1), :, 1, 1)), 1, 4) with eltype Float64:
 0.0577725  -0.493364  -0.126571  1.44218

julia> ArrayInterface.StrideIndex(u_final)
ArrayInterface.StrideIndex{2, (1, 2), 1, Tuple{Static.StaticInt{1}, Int64}, Tuple{Static.StaticInt{1}, Static.StaticInt{1}}}((static(1), 1), (static(1), static(1)))

I'm using Julia v1.7.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions