Jutho / TensorOperations.jl

Julia package for tensor contractions and related operations
https://jutho.github.io/TensorOperations.jl/stable/
Other
443 stars 56 forks source link

fix scalar multplication with multiple factors #131

Closed fatteneder closed 1 year ago

fatteneder commented 1 year ago

Fixes the following MWEs

using TensorOperations
const TO = TensorOperations

function test(ex)
    @show ex
    @show TO.isgeneraltensor(ex)
    try
        @show TO.decomposegeneraltensor(ex)
    catch e
        @show e
    end
    println()
end

test(:(a * A[i,j] * a))
test(:(a * a * A[i,j]))

Current main:

julia> include("mwe.jl")
ex = :(a * A[i, j] * a)
TO.isgeneraltensor(ex) = true
e = ArgumentError("not a valid generalized tensor expression a * A[i, j] * a")

ex = :(a * a * A[i, j])
TO.isgeneraltensor(ex) = true
e = ArgumentError("not a valid generalized tensor expression a * a * A[i, j]")

This PR:

julia> include("mwe.jl")
ex = :(a * A[i, j] * a)
TO.isgeneraltensor(ex) = true
TO.decomposegeneraltensor(ex) = (:A, Any[:i, :j], Any[], :(a * true * a), false)

ex = :(a * a * A[i, j])
TO.isgeneraltensor(ex) = true
TO.decomposegeneraltensor(ex) = (:A, Any[:i, :j], Any[], :(a * a * true), false)
codecov[bot] commented 1 year ago

Codecov Report

Merging #131 (6098d35) into master (7181632) will increase coverage by 0.50%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #131      +/-   ##
==========================================
+ Coverage   77.12%   77.63%   +0.50%     
==========================================
  Files          22       22              
  Lines        1985     1985              
==========================================
+ Hits         1531     1541      +10     
+ Misses        454      444      -10     
Impacted Files Coverage Δ
src/indexnotation/analyzers.jl 85.90% <100.00%> (+4.69%) :arrow_up:

... and 2 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more