本文整理汇总了Python中sympy.printing.pretty.stringpict.stringPict函数的典型用法代码示例。如果您正苦于以下问题:Python stringPict函数的具体用法?Python stringPict怎么用?Python stringPict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stringPict函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _pretty_brackets
def _pretty_brackets(self, height, use_unicode=True):
# Return pretty printed brackets for the state
# Ideally, this could be done by pform.parens but it does not support the angled < and >
# Setup for unicode vs ascii
if use_unicode:
lbracket, rbracket = self.lbracket_ucode, self.rbracket_ucode
slash, bslash, vert = u'\u2571', u'\u2572', u'\u2502'
else:
lbracket, rbracket = self.lbracket, self.rbracket
slash, bslash, vert = '/', '\\', '|'
# If height is 1, just return brackets
if height == 1:
return stringPict(lbracket), stringPict(rbracket)
# Make height even
height += (height % 2)
brackets = []
for bracket in lbracket, rbracket:
# Create left bracket
if bracket in set([_lbracket, _lbracket_ucode]):
bracket_args = [ ' ' * (height//2-i-1) + slash for i in range(height // 2)]
bracket_args.extend([ ' ' * i + bslash for i in range(height // 2)])
# Create right bracket
elif bracket in set([_rbracket, _rbracket_ucode]):
bracket_args = [ ' ' * i + bslash for i in range(height // 2)]
bracket_args.extend([ ' ' * (height//2-i-1) + slash for i in range(height // 2)])
# Create straight bracket
elif bracket in set([_straight_bracket, _straight_bracket_ucode]):
bracket_args = [vert for i in range(height)]
else:
raise ValueError(bracket)
brackets.append(stringPict('\n'.join(bracket_args), baseline=height//2))
return brackets
开发者ID:BDGLunde,项目名称:sympy,代码行数:35,代码来源:state.py
示例2: _pretty
def _pretty(self, printer, *args):
top = printer._print(self.j)
bot = printer._print(self.m)
bot = prettyForm(*bot.right(","))
bot = prettyForm(*bot.right(printer._print(self.mp)))
pad = max(top.width(), bot.width())
top = prettyForm(*top.left(" "))
bot = prettyForm(*bot.left(" "))
if pad > top.width():
top = prettyForm(*top.right(" " * (pad - top.width())))
if pad > bot.width():
bot = prettyForm(*bot.right(" " * (pad - bot.width())))
if self.alpha == 0 and self.gamma == 0:
args = printer._print(self.beta)
s = stringPict("d" + " " * pad)
else:
args = printer._print(self.alpha)
args = prettyForm(*args.right(","))
args = prettyForm(*args.right(printer._print(self.beta)))
args = prettyForm(*args.right(","))
args = prettyForm(*args.right(printer._print(self.gamma)))
s = stringPict("D" + " " * pad)
args = prettyForm(*args.parens())
s = prettyForm(*s.above(top))
s = prettyForm(*s.below(bot))
s = prettyForm(*s.right(args))
return s
开发者ID:hitej,项目名称:meta-core,代码行数:33,代码来源:spin.py
示例3: _pretty
def _pretty(self, printer, *args):
pform = printer._print(self.args[0], *args)
pform = prettyForm(*pform.right((prettyForm(','))))
pform = prettyForm(*pform.right((printer._print(self.args[1], *args))))
a = stringPict(u'\u03b4')
b = pform
top = stringPict(*b.left(' '*a.width()))
bot = stringPict(*a.right(' '*b.width()))
return prettyForm(binding=prettyForm.POW, *bot.below(top))
开发者ID:ArchKaine,项目名称:sympy,代码行数:9,代码来源:kronecker.py
示例4: _pretty
def _pretty(self, printer, *args):
controls = self._print_sequence_pretty(self.controls, ',', printer, *args)
gate = printer._print(self.gate)
gate_name = stringPict(unicode(self.gate_name))
first = self._print_subscript_pretty(gate_name, controls)
gate = self._print_parens_pretty(gate)
final = prettyForm(*first.right((gate)))
return final
开发者ID:yangle,项目名称:sympy,代码行数:8,代码来源:gate.py
示例5: test_printing
def test_printing():
for c in (LatexPrinter, LatexPrinter(), MathMLPrinter,
PrettyPrinter, prettyForm, stringPict, stringPict("a"),
Printer, Printer(), PythonPrinter, PythonPrinter()):
#FIXME-py3k: sympy/printing/printer.py", line 220, in order
#FIXME-py3k: return self._settings['order']
#FIXME-py3k: KeyError: 'order'
check(c)
开发者ID:Narsil,项目名称:sympy,代码行数:8,代码来源:test_pickling.py
示例6: test_printing
def test_printing():
for c in (
LatexPrinter,
LatexPrinter(),
MathMLPrinter,
PrettyPrinter,
prettyForm,
stringPict,
stringPict("a"),
Printer,
Printer(),
PythonPrinter,
PythonPrinter(),
):
check(c)
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:15,代码来源:test_pickling.py
示例7: _pretty
def _pretty(self, printer, *args):
bot = printer._print_seq((self.j1, self.m1, self.j2, self.m2), delimiter=',')
top = printer._print_seq((self.j3, self.m3), delimiter=',')
pad = max(top.width(), bot.width())
bot = prettyForm(*bot.left(' '))
top = prettyForm(*top.left(' '))
if not pad == bot.width():
bot = prettyForm(*bot.right(' ' * (pad-bot.width())))
if not pad == top.width():
top = prettyForm(*top.right(' ' * (pad-top.width())))
s = stringPict('C' + ' '*pad)
s = prettyForm(*s.below(bot))
s = prettyForm(*s.above(top))
return s
开发者ID:BDGLunde,项目名称:sympy,代码行数:16,代码来源:cg.py
示例8: _pretty
def _pretty(self, printer, *args):
bot = printer._print(self.j1)
bot = prettyForm(*bot.right(","))
bot = prettyForm(*bot.right(printer._print(self.m1)))
bot = prettyForm(*bot.right(","))
bot = prettyForm(*bot.right(printer._print(self.j2)))
bot = prettyForm(*bot.right(","))
bot = prettyForm(*bot.right(printer._print(self.m2)))
top = printer._print(self.j3)
top = prettyForm(*top.right(","))
top = prettyForm(*top.right(printer._print(self.m3)))
pad = max(top.width(), bot.width())
bot = prettyForm(*bot.left(" "))
top = prettyForm(*top.left(" "))
if not pad == bot.width():
bot = prettyForm(*bot.right(" " * (pad - bot.width())))
if not pad == top.width():
top = prettyForm(*top.right(" " * (pad - top.width())))
s = stringPict("C" + " " * pad)
s = prettyForm(*s.below(bot))
s = prettyForm(*s.above(top))
return s
开发者ID:nvlrules,项目名称:sympy,代码行数:24,代码来源:cg.py
示例9: _print_contents_pretty
def _print_contents_pretty(self, printer, *args):
a = stringPict(unicode(self.name))
b = stringPict(self._coord)
return self._print_subscript_pretty(a, b)
开发者ID:hitej,项目名称:meta-core,代码行数:4,代码来源:spin.py
注:本文中的sympy.printing.pretty.stringpict.stringPict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论