This looks like a bug. Can you open an issue for it? The problem is that it generates the code "array([])" for the empty matrix, but that creates a shape (0,) array. It should instead use empty((0, 0)) to create an empty array with the correct shape.
By the way, SymPy 1.5.1 is a relatively old version of SymPy. The newest version is 1.7.1 (although this issue still persists even in the git version). Aaron Meurer On Wed, Jan 6, 2021 at 4:00 AM Felipe Bordeu <[email protected]> wrote: > > Hello everyone, > > I'm trying to use lambdify on some matrix expression, but my problem is that > the shape of the matrix expr is not preserved. this is an example of my > problem: > > ''' > from sympy import Symbol, Matrix > from sympy.utilities.lambdify import lambdify > > xi = Symbol("xi") > eta = Symbol("eta") > phi = Symbol("phi") > > mat22 = Matrix([[xi+1,eta],[phi+2,eta]]) > mat11 = Matrix([[xi+1]]) > mat00 = Matrix([[]]) > print("shape of the expression") > print(mat22.shape) > print(mat11.shape) > print(mat00.shape) > > symbols = [xi,eta,phi] > args = [0,1,2] > print("shape of the lambdify expression") > print(lambdify(symbols,mat22)(*args).shape) > print(lambdify(symbols,mat11)(*args).shape) > print(lambdify(symbols,mat00)(*args).shape) > '' > output: > > shape of the expretion > (2, 2) > (1, 1) > (0, 0) > shape of the lambdify expretion > (2, 2) > (1, 1) > (0,) <----- i will like to have (0,0) > > Any idea on how to solve this issue > > using : > Python 3.6.10 |Anaconda, Inc.| (default, May 8 2020, 02:54:21) > [GCC 7.3.0] on linux > >>> sympy.__version__ > '1.5.1' > > Felipe > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/80b8258a-a76e-4c6c-a0c0-30911d481b13n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BEZPxvTxi7J8jgG6saCGBVO-QsbHvZ6n%3DtupMzvSHc%3DA%40mail.gmail.com.
