# ufl_legacy.formatting package

## Submodules

## ufl_legacy.formatting.graph module

Algorithms for working with linearized computational graphs.

class ufl_legacy.formatting.graph.Graph(expression)

  Bases: `object`

  Graph class which computes connectivity on demand.

  E()
  Ein()
  Eout()
  V()
  Vin()
  Vout()

class ufl_legacy.formatting.graph.HeapItem(incoming, outgoing, i)

  Bases: `object`

class ufl_legacy.formatting.graph.StringDependencyDefiner(argument_deps=None, coefficient_deps=None)

  Bases: `MultiFunction`

  Given an expr, returns a frozenset of its dependencies.

  Possible dependency values are:

    “c” - depends on runtime information like the cell, local<->global coordinate mappings, facet normals, or coefficients “x” - depends on local coordinates “v%d” % i - depends on argument i, for i in [0,rank)

  argument(x)
  coefficient(x)
  expr(o)

    Trigger error for types with missing handlers.

  facet_normal(o)
  geometric_quantity(x)
  spatial_derivative(o)

ufl_legacy.formatting.graph.build_graph(expr)

  Build a linearized graph from an UFL Expr.

  Returns G = (V, E), with V being a list of graph nodes (Expr objects) in post traversal ordering and E being a list of edges. Each edge is represented as a (i, j) tuple where i and j are vertex indices into V.

ufl_legacy.formatting.graph.depth_first_ordering(G)

ufl_legacy.formatting.graph.extract_incoming_edges(G)

  Build lists of incoming edges to each vertex in a linearized graph.

ufl_legacy.formatting.graph.extract_incoming_vertex_connections(G)

  Build lists of vertices in incoming and outgoing edges to and from each vertex in a linearized graph.

  Returns lists Vin and Vout.

ufl_legacy.formatting.graph.extract_outgoing_edges(G)

  Build list of outgoing edges from each vertex in a linearized graph.

ufl_legacy.formatting.graph.extract_outgoing_vertex_connections(G)

  Build lists of vertices in incoming and outgoing edges to and from each vertex in a linearized graph.

  Returns lists Vin and Vout.

ufl_legacy.formatting.graph.len_items(sequence)

ufl_legacy.formatting.graph.lists(n)

ufl_legacy.formatting.graph.partition(G, criteria=<function string_set_criteria>)

ufl_legacy.formatting.graph.string_set_criteria(v, keys)

## ufl_legacy.formatting.printing module

A collection of utility algorithms for printing of UFL objects, mostly intended for debugging purposes.

ufl_legacy.formatting.printing.form_info(form)

ufl_legacy.formatting.printing.integral_info(integral)

ufl_legacy.formatting.printing.tree_format(expression, indentation=0, parentheses=True)

## ufl_legacy.formatting.ufl2dot module

A collection of utility algorithms for printing of UFL objects in the DOT graph visualization language, mostly intended for debugging purposers.

class ufl_legacy.formatting.ufl2dot.CompactLabeller(function_mapping=None)

  Bases: `ReprLabeller`

  cell_avg(e)
  component_tensor(e)
  conj(e)
  curl(e)
  determinant(e)
  dev(e)
  diff(e)
  div(e)
  division(e)
  dot(e)
  facet_avg(e)
  form_argument(e)
  geometric_quantity(e)
  grad(e)
  identity(e)
  imag(e)
  index_sum(e)
  indexed(e)
  inner(e)
  math_function(e)
  multi_index(e)
  nabla_div(e)
  nabla_grad(e)
  negative_restricted(e)
  outer(e)
  positive_restricted(e)
  power(e)
  product(e)
  real(e)
  scalar_value(e)
  skew(e)
  sum(e)
  trace(e)
  transposed(e)
  zero(e)

class ufl_legacy.formatting.ufl2dot.FancyLabeller(function_mapping=None)

  Bases: `CompactLabeller`

class ufl_legacy.formatting.ufl2dot.ReprLabeller

  Bases: `MultiFunction`

  operator(e)
  terminal(e)

ufl_legacy.formatting.ufl2dot.build_entities(e, nodes, edges, nodeoffset, prefix='', labeller=None)

ufl_legacy.formatting.ufl2dot.format_entities(nodes, edges)

ufl_legacy.formatting.ufl2dot.ufl2dot(expression, formname='a', nodeoffset=0, begin=True, end=True, labeling='repr', object_names=None)

## ufl_legacy.formatting.ufl2unicode module

class ufl_legacy.formatting.ufl2unicode.Expression2UnicodeHandler(argument_names=None, coefficient_names=None, colorama_bold=False)

  Bases: `MultiFunction`

  abs(o, a)
  and_condition(o, a, b)
  argument(o)
  atan2(o, f1, f2)
  bessel_K(o, nu, f)
  bessel_i(o, nu, f)
  bessel_j(o, nu, f)
  bessel_y(o, nu, f)
  cell_avg(o, f)
  coefficient(o)
  coefficient_derivative(o, f, w, v, cd)
  cofactor(o, A)
  component_tensor(o, A, ii)
  conditional(o, c, t, f)
  conj(o, a)
  constant(o)
  cross(o, a, b)
  curl(o, f)
  determinant(o, A)
  deviatoric(o, A)
  div(o, f)
  division(o, a, b)
  dot(o, a, b)
  eq(o, a, b)
  exp(o, f)
  expr(o)

    Trigger error for types with missing handlers.

  expr_list(o, *ops)
  expr_mapping(o, *ops)
  facet_avg(o, f)
  facet_normal(o)
  ge(o, a, b)
  grad(o, f)
  gt(o, a, b)
  identity(o)
  imag(o, a)
  index_sum(o, f, i)
  indexed(o, A, ii)
  inner(o, a, b)
  inverse(o, A)
  label(o)
  le(o, a, b)
  list_tensor(o, *ops)
  lt(o, a, b)
  math_function(o, f)
  max_value(o, a, b)
  min_value(o, a, b)
  multi_index(o)
  nabla_div(o, f)
  nabla_grad(o, f)
  ne(o, a, b)
  negative_restricted(o, f)
  not_condition(o, a)
  or_condition(o, a, b)
  outer(o, a, b)
  permutation_symbol(o)
  positive_restricted(o, f)
  power(o, a, b)
  product(o, a, b)
  real(o, a)
  scalar_value(o)
  skew(o, A)
  spatial_coordinate(o)
  sqrt(o, f)
  sum(o, a, b)
  sym(o, A)
  trace(o, A)
  transposed(o, a)
  variable(o, f, l)
  variable_derivative(o, f, v)
  zero(o)

class ufl_legacy.formatting.ufl2unicode.PrecedenceRules

  Bases: `MultiFunction`

  An enum-like class for C operator precedence levels.

  add(o)
  and_condition(o)
  bessel_function(o)
  call(o)
  cell_avg(o)
  cofactor(o)
  component_tensor(o)
  conditional(o)
  cross(o)
  derivative(o)
  deviatoric(o)
  division(o)
  dot(o)
  eq(o)
  facet_avg(o)
  ge(o)
  gt(o)
  highest(o)
  index_sum(o)
  indexed(o)
  inner(o)
  le(o)
  list_tensor(o)
  lowest(o)
  lt(o)
  math_function(o)
  mathop(o)
  max_value(o)
  min_value(o)
  ne(o)
  not_condition(o)
  operator(o)
  or_condition(o)
  outer(o)
  power(o)
  product(o)
  restricted(o)
  skew(o)
  sym(o)
  terminal(o)
  trace(o)

class ufl_legacy.formatting.ufl2unicode.UC

  Bases: `object`

  An enum-like class for unicode characters.

  Gamma = 'Γ'
  Omega = 'Ω'
  bold_math_A = '𝐀'
  bold_math_a = '𝐚'
  circled_times = '⊗'
  combining_overline = '̅'
  combining_right_arrow_above = '⃗'
  cross_product = '⨯'
  division_slash = '∕'
  dot = '⋅'
  element_of = '∈'
  epsilon = 'ε'
  for_all = '∀'
  gamma = 'γ'
  ge = '≥'
  gt = '>'
  integral = '∫'
  integral_contour = '∮'
  integral_double = '∬'
  integral_surface = '∯'
  integral_triple = '∭'
  integral_volume = '∰'
  le = '≤'
  left_angled_bracket = '⟨'
  left_double_angled_bracket = '⟪'
  left_white_square_bracket = '⟦'
  logical_and = '∧'
  logical_not = '¬'
  logical_or = '∨'
  lt = '<'
  nabla = '∇'
  nary_product = '∏'
  ne = '≠'
  not_element_of = '∉'
  omega = 'ω'
  partial = '∂'
  right_angled_bracket = '⟩'
  right_double_angled_bracket = '⟫'
  right_white_squared_bracket = '⟧'
  sqrt = '√'
  subscript_digits = ['₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉']
  subscript_equals = '₌'
  subscript_left_paren = '₍'
  subscript_minus = '₋'
  subscript_plus = '₊'
  subscript_right_paren = '₎'
  sum = '∑'
  superscript_digits = ['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹']
  superscript_equals = '⁼'
  superscript_left_paren = '⁽'
  superscript_minus = '⁻'
  superscript_plus = '⁺'
  superscript_right_paren = '⁾'
  thin_space = '\u2009'
  transpose = 'ᵀ'

ufl_legacy.formatting.ufl2unicode.binop(expr, a, b, op, sep=' ')

ufl_legacy.formatting.ufl2unicode.bolden_letter(c)

ufl_legacy.formatting.ufl2unicode.bolden_string(s)

ufl_legacy.formatting.ufl2unicode.expression2unicode(expression, argument_names=None, coefficient_names=None)

ufl_legacy.formatting.ufl2unicode.form2unicode(form, formdata)

ufl_legacy.formatting.ufl2unicode.format_index(ii)

ufl_legacy.formatting.ufl2unicode.get_integral_symbol(integral_type, domain, subdomain_id)

ufl_legacy.formatting.ufl2unicode.is_int(s)

ufl_legacy.formatting.ufl2unicode.mathop(expr, arg, opname)

ufl_legacy.formatting.ufl2unicode.measure_font(dx)

ufl_legacy.formatting.ufl2unicode.opfont(opname)

ufl_legacy.formatting.ufl2unicode.overline_string(f)

ufl_legacy.formatting.ufl2unicode.par(s)

ufl_legacy.formatting.ufl2unicode.prec(expr)

ufl_legacy.formatting.ufl2unicode.precedence(expr)

ufl_legacy.formatting.ufl2unicode.subscript_digit(digit)

ufl_legacy.formatting.ufl2unicode.subscript_number(number)

ufl_legacy.formatting.ufl2unicode.superscript_digit(digit)

ufl_legacy.formatting.ufl2unicode.superscript_number(number)

ufl_legacy.formatting.ufl2unicode.ufl2unicode(expression)

  Generate Unicode string for a UFL expression or form.

## Module contents