OMEinsum.jl icon indicating copy to clipboard operation
OMEinsum.jl copied to clipboard

Can't include constants in expression

Open ssfrr opened this issue 4 years ago • 1 comments

It seems that the @ein macro doesn't like having constants included. Interestingly it seems to throw a different error depending on whether you're multiplying or adding.

x = rand(10, 10)
@ein y[i] := x[i, j] * 2

Gives:

LoadError: type Nothing has no field inds
in expression starting at /home/sfr/research_journal/2020/02/26/spatial_subspace_sdr.jmd:177
getproperty(::Nothing, ::Symbol) at Base.jl:20
(::OMEinsum.var"#78#80")(::Nothing) at einsequence.jl:147
...
x = rand(10, 10)
@ein y[i] := x[i, j] + 2

gives

LoadError: type Nothing has no field iy
in expression starting at /home/sfr/research_journal/2020/02/26/spatial_subspace_sdr.jmd:177
getproperty(::Nothing, ::Symbol) at Base.jl:20
#_nested_ein_macro#74(::Symbol, ::typeof(OMEinsum._nested_ein_macro), ::Expr) at einsequence.jl:136
_nested_ein_macro at einsequence.jl:121 [inlined]
#_ein_macro#69(::Symbol, ::typeof(OMEinsum._ein_macro), ::Expr) at interfaces.jl:157
...

ssfrr avatar Feb 26 '20 17:02 ssfrr

Addition is actually not supported so we probably should throw an error there (not sure what happens under the hood there but I'll look at it).

The issue with the constant is a bit unfortunate and it should probably work.

under-Peter avatar Feb 26 '20 17:02 under-Peter

I do not think we will have scalar in the einsum expression in near future.

GiggleLiu avatar Sep 23 '23 19:09 GiggleLiu