def apply_makeboxes(self, table, f, evaluation, options): '''MakeBoxes[%(name)s[table_, OptionsPattern[%(name)s]], f:StandardForm|TraditionalForm|OutputForm]''' dims = len(get_dimensions(table, head=Symbol('List'))) depth = self.get_option(options, 'TableDepth', evaluation).unformatted depth = expr_min((Integer(dims), depth)) depth = depth.get_int_value() if depth is None: evaluation.message(self.get_name(), 'int') return if depth <= 0: return Expression('MakeBoxes', table, f) elif depth == 1: return Expression( 'GridBox', Expression('List', *( Expression('List', Expression('MakeBoxes', item, f)) for item in table.leaves))) else: new_depth = Expression('Rule', Symbol('TableDepth'), depth - 2) def transform_item(item): if depth > 2: return Expression(self.get_name(), item, new_depth) else: return item return Expression( 'GridBox', Expression('List', *( Expression('List', *( Expression('MakeBoxes', transform_item(item), f) for item in row.leaves)) for row in table.leaves)))
def apply_makeboxes(self, table, f, evaluation, options): """MakeBoxes[%(name)s[table_, OptionsPattern[%(name)s]], f:StandardForm|TraditionalForm|OutputForm]""" dims = len(get_dimensions(table, head=Symbol("List"))) depth = self.get_option(options, "TableDepth", evaluation).unformatted depth = expr_min((Integer(dims), depth)) depth = depth.get_int_value() if depth is None: evaluation.message(self.get_name(), "int") return if depth <= 0: return Expression("MakeBoxes", table, f) elif depth == 1: return Expression( "GridBox", Expression("List", *(Expression("List", Expression("MakeBoxes", item, f)) for item in table.leaves)), ) else: new_depth = Expression("Rule", Symbol("TableDepth"), depth - 2) def transform_item(item): if depth > 2: return Expression(self.get_name(), item, new_depth) else: return item return Expression( "GridBox", Expression( "List", *( Expression("List", *(Expression("MakeBoxes", transform_item(item), f) for item in row.leaves)) for row in table.leaves ) ), )