53 lines
2.0 KiB
Diff
53 lines
2.0 KiB
Diff
--- sympy-sympy-1.2/sympy/utilities/lambdify.py.orig 2018-08-14 12:45:57.659778760 +0200
|
|
+++ sympy-sympy-1.2/sympy/utilities/lambdify.py 2018-08-14 12:46:12.412849733 +0200
|
|
@@ -741,8 +741,7 @@
|
|
|
|
return argstrs, expr
|
|
|
|
- @staticmethod
|
|
- def _subexpr(expr, dummies_dict):
|
|
+ def _subexpr(self, expr, dummies_dict):
|
|
from sympy.matrices import DeferredVector
|
|
from sympy import sympify
|
|
|
|
@@ -752,13 +751,13 @@
|
|
if isinstance(expr, DeferredVector):
|
|
pass
|
|
elif isinstance(expr, dict):
|
|
- k = [sub_expr(sympify(a), dummies_dict) for a in expr.keys()]
|
|
- v = [sub_expr(sympify(a), dummies_dict) for a in expr.values()]
|
|
+ k = [self._subexpr(sympify(a), dummies_dict) for a in expr.keys()]
|
|
+ v = [self._subexpr(sympify(a), dummies_dict) for a in expr.values()]
|
|
expr = dict(zip(k, v))
|
|
elif isinstance(expr, tuple):
|
|
- expr = tuple(sub_expr(sympify(a), dummies_dict) for a in expr)
|
|
+ expr = tuple(self._subexpr(sympify(a), dummies_dict) for a in expr)
|
|
elif isinstance(expr, list):
|
|
- expr = [sub_expr(sympify(a), dummies_dict) for a in expr]
|
|
+ expr = [self._subexpr(sympify(a), dummies_dict) for a in expr]
|
|
return expr
|
|
|
|
def _print_funcargwrapping(self, args):
|
|
|
|
--- sympy-sympy-1.2/sympy/utilities/tests/test_lambdify.py.orig 2018-08-14 12:46:10.396840035 +0200
|
|
+++ sympy-sympy-1.2/sympy/utilities/tests/test_lambdify.py 2018-08-14 12:46:12.413849738 +0200
|
|
@@ -883,3 +883,18 @@
|
|
# Test that inspect.getsource works but don't hard-code implementation
|
|
# details
|
|
assert 'x**2' in inspect.getsource(f)
|
|
+
|
|
+def test_issue_14941():
|
|
+ x, y = Dummy(), Dummy()
|
|
+
|
|
+ # test dict
|
|
+ f1 = lambdify([x, y], {x: 3, y: 3}, 'sympy')
|
|
+ assert f1(2, 3) == {2: 3, 3: 3}
|
|
+
|
|
+ # test tuple
|
|
+ f2 = lambdify([x, y], (y, x), 'sympy')
|
|
+ assert f2(2, 3) == (3, 2)
|
|
+
|
|
+ # test list
|
|
+ f3 = lambdify([x, y], [y, x], 'sympy')
|
|
+ assert f3(2, 3) == [3, 2]
|