Skip to content

Representation

Representation

Bases: Repr

Representation class for the library.

Attributes

T class-attribute instance-attribute

T = TypeVar('T')

fll instance-attribute

fll: Final = FllExporter()

maxlevel instance-attribute

maxlevel = 10

repr_float128 class-attribute instance-attribute

repr_float128 = repr_float

repr_float16 class-attribute instance-attribute

repr_float16 = repr_float

repr_float32 class-attribute instance-attribute

repr_float32 = repr_float

repr_float64 class-attribute instance-attribute

repr_float64 = repr_float

Functions

__init__

__init__() -> None

Constructor.

__repr__

__repr__() -> str

Return code to construct the representation in Python.

Returns:

Type Description
str

code to construct the representation in Python

as_constructor

as_constructor(
    x: T, /, fields: dict[str, Any] | None = None, *, positional: bool = False, cast_as: type[T] | None = None
) -> str

Return the Python code to use the constructor of the object.

Parameters:

Name Type Description Default
x T

object to construct

required
fields dict[str, Any] | None

override the parameters and arguments to use in the constructor

None
positional bool

use positional parameters if true, and keyword parameters otherwise

False
cast_as type[T] | None

type to upcast the object (useful in inheritance approaches)

None

Returns:

Type Description
str

Python code to use the constructor of the object.

construction_arguments

construction_arguments(
    x: T, /, fields: dict[str, Any] | None = None, *, positional: bool = False, cast_as: type[T] | None = None
) -> list[str]

Return the list of parameters and arguments for the constructor of the object.

Parameters:

Name Type Description Default
x T

object to construct

required
fields dict[str, Any] | None

override the parameters and arguments to use in the constructor

None
positional bool

use positional parameters if true, and keyword parameters otherwise

False
cast_as type[T] | None

type to upcast the object (useful in inheritance approaches)

None

Returns:

Type Description
list[str]

list of parameters and arguments for the constructor of the object.

import_statement

import_statement() -> str

Return the library's import statement based on the alias in the settings.

related

Returns:

Type Description
str

library's import statement based on the alias in the settings.

package_of

package_of(x: Any) -> str

Return the qualified class name of the object.

Parameters:

Name Type Description Default
x Any

object to get package of

required

Returns:

Type Description
str

qualified class name of the object.

repr_float

repr_float(x: float | floating[Any], level: int) -> str

Return the string representation of the floating-point value in Python.

Parameters:

Name Type Description Default
x float | floating[Any]

float to represent

required
level int

irrelevant

required

Returns:

Type Description
str

string representation of the floating-point value in Python.

repr_ndarray

repr_ndarray(x: Array[Any], level: int) -> str

Return the string representation of the numpy array in Python.

Parameters:

Name Type Description Default
x Array[Any]

numpy array to represent

required
level int

level for recursion control

required

Returns:

Type Description
str

string representation of the numpy array in Python