本文整理汇总了Python中mathics.core.expression.Expression.boxes_to_text方法的典型用法代码示例。如果您正苦于以下问题:Python Expression.boxes_to_text方法的具体用法?Python Expression.boxes_to_text怎么用?Python Expression.boxes_to_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathics.core.expression.Expression
的用法示例。
在下文中一共展示了Expression.boxes_to_text方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: format_output
# 需要导入模块: from mathics.core.expression import Expression [as 别名]
# 或者: from mathics.core.expression.Expression import boxes_to_text [as 别名]
def format_output(self, expr, format=None):
if format is None:
format = self.format
if isinstance(format, dict):
return dict((k, self.format_output(expr, f)) for k, f in format.items())
from mathics.core.expression import Expression, BoxError
if format == 'text':
result = expr.format(self, 'System`OutputForm')
elif format == 'xml':
result = Expression(
'StandardForm', expr).format(self, 'System`MathMLForm')
elif format == 'tex':
result = Expression('StandardForm', expr).format(
self, 'System`TeXForm')
else:
raise ValueError
try:
boxes = result.boxes_to_text(evaluation=self)
except BoxError:
self.message('General', 'notboxes',
Expression('FullForm', result).evaluate(self))
boxes = None
return boxes
示例2: format_output
# 需要导入模块: from mathics.core.expression import Expression [as 别名]
# 或者: from mathics.core.expression.Expression import boxes_to_text [as 别名]
def format_output(self, expr):
from mathics.core.expression import Expression, String, BoxError
if self.format == 'text':
result = expr.format(self, 'OutputForm')
elif self.format == 'xml':
result = Expression('StandardForm', expr).format(self, 'MathMLForm')
elif self.format == 'tex':
result = Expression('StandardForm', expr).format(self, 'TeXForm')
else:
raise ValueError
try:
boxes = result.boxes_to_text(evaluation=self)
except BoxError:
self.message('General', 'notboxes', String('%s' % result))
boxes = None
return boxes