From 2d33e5afb08a762d15aee802f2fa8176a0ebe31d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 25 Jan 2018 22:38:20 -0600 Subject: [PATCH] Let build_matrix tolerate single expressions --- pytential/symbolic/execution.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pytential/symbolic/execution.py b/pytential/symbolic/execution.py index 3e96b00c..213eb428 100644 --- a/pytential/symbolic/execution.py +++ b/pytential/symbolic/execution.py @@ -406,8 +406,10 @@ def build_matrix(queue, places, expr, input_exprs, domains=None, :arg places: a mapping of symbolic names to :class:`pytential.discretization.Discretization` objects or a subclass of :class:`pytential.discretization.target.TargetBase`. - :arg input_exprs: A sequence of expressions corresponding to the + :arg input_exprs: An object array of expressions corresponding to the input block columns of the matrix. + + May also be a single expression. :arg domains: a list of discretization identifiers (see 'places') or *None* values indicating the domains on which each component of the solution vector lives. *None* values indicate that the component @@ -432,6 +434,12 @@ def build_matrix(queue, places, expr, input_exprs, domains=None, domains = _domains_default(len(input_exprs), places, domains, DEFAULT_SOURCE) + try: + iter(input_exprs) + except TypeError: + # not iterable, wrap in a list + input_exprs = [input_exprs] + input_exprs = list(input_exprs) nblock_rows = len(expr) -- GitLab