def _needs_mul_brackets(self, expr, last=False):
"""
Returns True if the expression needs to be wrapped in brackets when
printed as part of a Mul, False otherwise. This is True for Add,
but also for some container objects that would not need brackets
when appearing last in a Mul, e.g. an Integral. ``last=True``
specifies that this expr is the last to appear in a Mul.
"""
from sympy import Integral, Piecewise, Product, Sum
return expr.is_Add or (not last and
any([expr.has(x) for x in (Integral, Piecewise, Product, Sum)]))
评论列表
文章目录