Skip to content

tensortrace not working on Arrays of Symbolic Expressions from Symbolics.jl. #163

Open
@Sollovin

Description

@Sollovin

Hi, I got a problem when I'm trying to use Symbolics.jl and TensorOperations.jl together.
tensortrace not working on Arrays of Symbolic Expressions from Symbolics.jl.

Minimal code reproduces the error:

using Symbolics, TensorOperations

tensor2 = Symbolics.variables(:ρ, 1:6, 1:2, 1:2, 1:6, 1:2, 1:2)
tensortrace(tensor2, (1, 2, 3, 1, 4, 5))

which gives out

ERROR: MethodError: scalartype(::Type{Union{}}) is ambiguous.

Candidates:
  scalartype(::Type{T}) where T<:Number
    @ VectorInterface ~/.julia/packages/VectorInterface/TAlcJ/src/number.jl:6
  scalartype(::Type{A}) where {T, A<:(AbstractArray{T})}
    @ VectorInterface ~/.julia/packages/VectorInterface/TAlcJ/src/abstractarray.jl:7
  scalartype(::Type{<:Tuple{T, Vararg{T}}}) where T
    @ VectorInterface ~/.julia/packages/VectorInterface/TAlcJ/src/tuple.jl:12
  scalartype(::Type{TT}) where TT<:Tuple
    @ VectorInterface ~/.julia/packages/VectorInterface/TAlcJ/src/tuple.jl:13

Possible fix, define
  scalartype(::Type{Union{}})

Stacktrace:
  [1] scalartype(::Type{Array{Union{}, 4}})
    @ VectorInterface ~/.julia/packages/VectorInterface/TAlcJ/src/abstractarray.jl:7
  [2] tensoralloc(::Type{Array{Union{}, 4}}, ::NTuple{4, Int64}, ::Bool)
    @ TensorOperations ~/.julia/packages/TensorOperations/LAzcX/src/implementation/allocator.jl:90
  [3] tensoralloc_add(::Type, ::Tuple{NTuple{4, Int64}, Tuple{}}, ::Array{Num, 6}, ::Symbol, ::Bool)
    @ TensorOperations ~/.julia/packages/TensorOperations/LAzcX/src/implementation/allocator.jl:36
  [4] tensoralloc_add(TC::Type, pC::Tuple{NTuple{4, Int64}, Tuple{}}, A::Array{Num, 6}, conjA::Symbol)
    @ TensorOperations ~/.julia/packages/TensorOperations/LAzcX/src/implementation/allocator.jl:34
  [5] tensortrace(::Tuple{NTuple{…}, Tuple{}}, ::Array{Num, 6}, ::Tuple{Tuple{…}, Tuple{…}}, ::Symbol, ::VectorInterface.One)
    @ TensorOperations ~/.julia/packages/TensorOperations/LAzcX/src/implementation/functions.jl:168
  [6] tensortrace(IC::NTuple{4, Int64}, A::Array{Num, 6}, IA::NTuple{6, Int64}, conjA::Symbol, α::VectorInterface.One)
    @ TensorOperations ~/.julia/packages/TensorOperations/LAzcX/src/implementation/functions.jl:146
  [7] tensortrace(IC::Vector{Int64}, A::Array{Num, 6}, IA::NTuple{6, Int64}, conjA::Symbol, α::VectorInterface.One)
    @ TensorOperations ~/.julia/packages/TensorOperations/LAzcX/src/implementation/functions.jl:162
  [8] tensortrace
    @ TensorOperations ~/.julia/packages/TensorOperations/LAzcX/src/implementation/functions.jl:158 [inlined]
  [9] tensortrace(A::Array{Num, 6}, IA::NTuple{6, Int64})
    @ TensorOperations ~/.julia/packages/TensorOperations/LAzcX/src/implementation/functions.jl:158
 [10] top-level scope
    @ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions