本文整理汇总了Python中stringpict.prettyForm.__mul__函数的典型用法代码示例。如果您正苦于以下问题:Python __mul__函数的具体用法?Python __mul__怎么用?Python __mul__使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了__mul__函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _print_MatMul
def _print_MatMul(self, expr):
a = list(expr.args)
for i in xrange(0, len(a)):
if a[i].is_Add and len(a) > 1:
a[i] = prettyForm(*self._print(a[i]).parens())
else:
a[i] = self._print(a[i])
return prettyForm.__mul__(*a)
开发者ID:meo-meo,项目名称:sympy,代码行数:9,代码来源:pretty.py
示例2: _print_Mul
def _print_Mul(self, product):
a = [] # items in the numerator
b = [] # items that are in the denominator (if any)
if self.order != 'old':
args = product.as_ordered_factors()
else:
args = product.args
# Gather terms for numerator/denominator
for item in args:
if item.is_Pow and item.exp.is_Rational and item.exp.is_negative:
b.append(C.Pow(item.base, -item.exp))
elif item.is_Rational and item is not S.Infinity:
if item.p != 1:
a.append( C.Rational(item.p) )
if item.q != 1:
b.append( C.Rational(item.q) )
else:
a.append(item)
# Convert to pretty forms. Add parens to Add instances if there
# is more than one term in the numer/denom
for i in xrange(0, len(a)):
if a[i].is_Add and len(a) > 1:
a[i] = prettyForm(*self._print(a[i]).parens())
else:
a[i] = self._print(a[i])
for i in xrange(0, len(b)):
if b[i].is_Add and len(b) > 1:
b[i] = prettyForm(*self._print(b[i]).parens())
else:
b[i] = self._print(b[i])
# Construct a pretty form
if len(b) == 0:
return prettyForm.__mul__(*a)
else:
if len(a) == 0:
a.append( self._print(S.One) )
return prettyForm.__mul__(*a) / prettyForm.__mul__(*b)
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:42,代码来源:pretty.py
注:本文中的stringpict.prettyForm.__mul__函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论