I am trying to use numpys numpy.einsum
function on symbolic sympy
arrays due to sympys cruel lack of einstein summation convention capabilities. I have tried this so far:
>>> from sympy import *
>>> import numpy as np
>>> a11,a12,a13,a21,a22,a23,a31,a32,a33 = symbols('a11,a12,a13,a21,a22,a23,a31,a32,a33')
>>> np.einsum('ii', a)
Traceback (most recent call last):
File "<pyshell#469>", line 1, in <module>
np.einsum('ii', a)
File "C:\Python35\lib\site-packages\numpy\core\einsumfunc.py", line 948, in einsum
return c_einsum(*operands, **kwargs)
TypeError: invalid data type for einsum
>>> a = Array([[a11,a12,a13],[a21,a22,a23],[a31,a32,a33]])
>>> np.einsum('ii', a)
Traceback (most recent call last):
File "<pyshell#472>", line 1, in <module>
np.einsum('ii', a)
File "C:\Python35\lib\site-packages\numpy\core\einsumfunc.py", line 948, in einsum
return c_einsum(*operands, **kwargs)
ValueError: einstein sum subscripts string contains too many subscripts for operand 0
As you can see I have tried passing both a numpy
native array and also a sympy
array both with no success. Is this sort of mixing (for data types across modules) possible for python classes in general but also for this situation in specific?