You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is this expected behaviour? A_1 or A_whatever, etc. works fine.
I have spent some time debugging this, since A_{longer text} is a valid Latex expression for long subscripts.
Should A = sym.MatrixSymbol("A_{whatever}", 3, 3) raise some parsing error before proceeding?
The text was updated successfully, but these errors were encountered:
In the code printer if you use a name that is not a valid python identifier it has to be replaced by a different name (in the _EvaluatorPrinter._preprocess method):
"""Preprocess args, expr to replace arguments that do not map
to valid Python identifiers.
Returns string form of args, and updated expr.
"""
That replaces the MatrixSymbol with a Dummy but MatMul sees the Dummy as a commutative scalar and swaps the order of multiplication.
It would be better if the code printer didn't actually modify the expression at all and just hooked into the way that symbols are printed to change the names at that point.
python3.7.5
sympy version: 1.7
numpy version: 1.19.5
Base case (working)
The code below executes normally
returns
Modified case (fails)
However, when I change
A = sym.MatrixSymbol("A", 3, 3)
toA = sym.MatrixSymbol("A_{whatever}", 3, 3)
this seems to break things, and this lineresults in an error:
Is this expected behaviour?
A_1
orA_whatever
, etc. works fine.I have spent some time debugging this, since
A_{longer text}
is a valid Latex expression for long subscripts.Should
A = sym.MatrixSymbol("A_{whatever}", 3, 3)
raise some parsing error before proceeding?The text was updated successfully, but these errors were encountered: