Skip to content

Commit 4bcebf9

Browse files
committed
compatibility: make lambdify more sympy-like
1 parent 345591b commit 4bcebf9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

symengine/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@
5252
from .lib.symengine_wrapper import ComplexMPC
5353

5454
if have_numpy:
55-
from .lib.symengine_wrapper import (Lambdify, LambdifyCSE)
56-
55+
from .lib.symengine_wrapper import Lambdify, LambdifyCSE
5756
def lambdify(args, exprs, **kwargs):
57+
if isinstance(exprs, Basic):
58+
exprs = [exprs]
5859
return Lambdify(args, *exprs, **kwargs)
5960
else:
6061
def __getattr__(name):
61-
if name == 'lambdify':
62-
raise AttributeError("Cannot import numpy, which is required for `lambdify` to work")
62+
if name in ('lambdify', 'Lambdify', 'LambdifyCSE'):
63+
raise AttributeError(f"Cannot import numpy, which is required for `{name}` to work")
6364
raise AttributeError(f"module 'symengine' has no attribute '{name}'")
6465

6566

symengine/utilities.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .lib.symengine_wrapper import Symbol, Basic
2+
23
from itertools import combinations, permutations, product, product as cartes
34
import re as _re
45
import string

0 commit comments

Comments
 (0)