drytorch.utils.repr_utils

Module containing utilities to extract readable representations.

MAX_DEPTH

Max number of recursions when representing an object.

Type:

int

MAX_REPR_SIZE

Max representation size for iterators and arrays.

Type:

int

INCLUDE_PROPERTIES

Whether to evaluate properties and represent them.

Type:

bool

Functions

recursive_repr(...)

Create a hierarchical representation of an object.

Classes

CreatedAtMixin(*args, **kwargs)

Mixin saving instantiation timestamp.

DefaultName()

Add a counter to a prefix.

LiteralStr

YAML will attempt to use the pipe style for this class.

Omitted([count])

Represent omitted values in an iterable object.

PandasPrintOptions([precision, max_rows, ...])

Context manager to temporarily set Pandas display options.

recursive_repr(obj: object, *, depth: int | None = None) Any[source]
recursive_repr(obj: Omitted, *, depth: int = 10) Omitted
recursive_repr(obj: str, *, depth: int = 10) str
recursive_repr(obj: None, *, depth: int = 10) None
recursive_repr(obj: Number, *, depth: int = 10) Number
recursive_repr(obj: tuple, *, depth: int = 1) tuple[Any, ...]
recursive_repr(obj: list, *, depth: int = 10) list[Any]
recursive_repr(obj: set, *, depth: int = 10) set[Hashable]
recursive_repr(obj: dict, *, depth: int = 10) dict[str, Any]
recursive_repr(obj: Tensor, *, depth: int = 10) LiteralStr
recursive_repr(obj: ndarray, *, depth: int = 10) LiteralStr
recursive_repr(obj: type, *, depth: int = 10) str
recursive_repr(obj: LambdaType, *, depth: int = 10) str
recursive_repr(obj: NDFrame, *, depth: int = 10) LiteralStr

Create a hierarchical representation of an object.

It recursively represents each attribute of the object or the contained items in tuples, lists, sets, and dictionaries. The latter structures are limited in size by limiting the number of elements and replacing the others with an Omitted instance. Arrays are represented using native representation Numbers are returned as they are or converted to built-in types.

Parameters:
  • obj (object) – The object to represent

  • depth (int | None) – Maximum recursion depth allowed

Returns:

A readable representation of the object

Return type:

Any