← All challenges
mediumsympy/sympy · v1.2

lambdify does not work with certain MatrixSymbol names even with dummify=True

Try this bug with AI

Fix it in the original repo with an AI agent and get feedback on how you worked.

2 free rounds each week

Round mode
  • Time limit60 min
  • Token budgetup to 1M
  • Worth up to210 XP
Sign up or sign in to start

Read the sample report

From a simulated Django round

You changed code before reproducing the bug.

Run the failing test before the first edit, so you know the failure you are fixing and can tell when it is gone.

Problem statement

lambdify is happy with curly braces in a symbol name and with MatrixSymbols, but not with both at the same time, even if dummify is True.

Here is some basic code that gives the error.

import sympy as sy
curlyx = sy.symbols("{x}")
v = sy.MatrixSymbol("v", 2, 1)
curlyv = sy.MatrixSymbol("{v}", 2, 1)

The following two lines of code work:

curlyScalarId = sy.lambdify(curlyx, curlyx)
vectorId = sy.lambdify(v,v)

The following two lines of code give a SyntaxError:

curlyVectorId = sy.lambdify(curlyv, curlyv)
curlyVectorIdDummified = sy.lambdify(curlyv, curlyv, dummify=True)
The environment starts at commit b7c5ba2bf3ff (sympy/sympy 1.2), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.