skyscapes._repr#

Shared formatting helpers for hierarchical __repr__ methods.

Each leaf class in skyscapes (atmospheres, disks, stars, zodi) defines its own multi-line __repr__; aggregator classes (Planet, System, Scene) use indent() to nest the children one level deeper. The result is a tree-shaped summary that lets you call repr(scene) in a notebook and see everything in the scene at a glance.

Functions#

indent(text[, prefix])

Prefix every line of text with prefix.

fmt_scalar_or_array(x[, fmt, max_items])

Format a scalar or small array compactly.

Module Contents#

skyscapes._repr.indent(text, prefix='  ')[source]#

Prefix every line of text with prefix.

Used by aggregator-class reprs (Scene, System, Planet) to nest the child reprs one level deeper.

Parameters:
Return type:

str

skyscapes._repr.fmt_scalar_or_array(x, fmt='.3g', max_items=3)[source]#

Format a scalar or small array compactly.

For a scalar (shape () or (1,)): formats as "3.14". For a short array: formats as "[3.14, 2.72, 1.41]". For a long array: formats as "[3.14, 2.72, ... (N=20)]".

Parameters:
  • x (jaxtyping.Array)

  • fmt (str)

  • max_items (int)

Return type:

str