assertionlib.ndrepr

A module for holding the NDRepr class, a subclass of the builtin reprlib.Repr class.

Index

NDRepr(**kwargs)

A subclass of reprlib.Repr with methods for handling additional object types.

Type-specific repr methods:

NDRepr.repr_float

Create a str representation of a float instance.

NDRepr.repr_Exception

Create a str representation of an :exc`Exception` instance.

NDRepr.repr_Signature

Create a str representation of a Signature instance.

NDRepr.repr_method

Create a str representation of a bound method.

NDRepr.repr_method_descriptor

Create a str representation of an unbound method.

NDRepr.repr_function

Create a str representation of a function.

NDRepr.repr_builtin_function_or_method

Create a str representation of a builtin function or method.

NDRepr.repr_type

Create a str representation of a type object.

NDRepr.repr_module

Create a str representation of a module.

NDRepr.repr_dict_keys

Create a str representation of a KeysView.

NDRepr.repr_dict_values

Create a str representation of a ValuesView.

NDRepr.repr_dict_items

Create a str representation of a ItemsView.

NDRepr.repr_Molecule

Create a str representation of a plams.Molecule instance.

NDRepr.repr_Settings

Create a str representation of a plams.Settings instance.

NDRepr.repr_Atom

Create a str representation of a plams.Atom instance.

NDRepr.repr_Bond

Create a str representation of a plams.Bond instance.

NDRepr.repr_ndarray

Create a str representation of a numpy.ndarray instance.

NDRepr.repr_DataFrame

Create a str representation of a pandas.DataFrame instance.

NDRepr.repr_Series

Create a str representation of a pandas.Series instance.

NDRepr.repr_Dataset

Create a str representation of a h5py.Dataset instance.

API

class assertionlib.ndrepr.NDRepr(**kwargs: int | Mapping[str, Any])[source]

A subclass of reprlib.Repr with methods for handling additional object types.

Has additional methods for handling:

  • PLAMS Molecules, Atoms, Bonds and Settings

  • NumPy arrays

  • Pandas Series and DataFrames

  • Callables

Parameters:

**kwargs (object) – User-specified values for one or more NDRepr instance attributes. An AttributeError is raised upon encountering unrecognized keys.

maxSignature

The maximum length of callables’ signatures before further parameters are truncated. See also NDRepr.repr_Signature().

Type:

int

maxfloat

The number of to-be displayed float decimals. See also NDRepr.repr_float().

Type:

int

maxMolecule

The maximum number of to-be displayed atoms and bonds in PLAMS molecules. See also NDRepr.repr_Molecule().

Type:

int

maxndarray

The maximum number of items in a numpy.ndarray row. Passed as argument to the numpy.printoptions() function:

  • threshold = self.maxndarray

  • edgeitems = self.maxndarray // 2

See also NDRepr.repr_ndarray().

Type:

int

maxSeries

The maximum number of rows per pandas.Series instance. Passed as value to pandas.options.display.

  • pandas.options.display.max_rows = self.series

See also NDRepr.repr_Series().

Type:

int

maxDataFrame

The maximum number of rows per pandas.DataFrame instance. Passed as values to pandas.options.display:

  • pandas.options.display.max_rows = self.maxdataframe

  • pandas.options.display.max_columns = self.maxdataframe // 2

See also NDRepr.repr_DataFrame().

Type:

int

np_printoptions

Additional keyword arguments for numpy.printoptions().

Note

Arguments provided herein will take priority over those specified internally in NDRepr.repr_ndarray().

Type:

dict

pd_printoptions

Additional “keyword arguments” for pandas.options.

Note

Arguments provided herein will take priority over those specified internally in NDRepr.repr_DataFrame() and NDRepr.repr_Series().

Type:

dict

NDRepr.repr_float(obj: float, level: int) str[source]

Create a str representation of a float instance.

NDRepr.repr_Exception(obj: Exception, level: int) str[source]

Create a str representation of an :exc`Exception` instance.

NDRepr.repr_Signature(obj: Signature, level: int) str[source]

Create a str representation of a Signature instance.

NDRepr.repr_method(obj: builtins.method, level: int) str[source]

Create a str representation of a bound method.

NDRepr.repr_method_descriptor(obj: builtins.method_descriptor, level: int) str[source]

Create a str representation of an unbound method.

NDRepr.repr_function(obj: builtins.function, level: int) str[source]

Create a str representation of a function.

NDRepr.repr_builtin_function_or_method(obj: builtins.builtin_function_or_method, level: int) str[source]

Create a str representation of a builtin function or method.

NDRepr.repr_type(obj: type, level: int) str[source]

Create a str representation of a type object.

NDRepr.repr_module(obj: builtins.module, level: int) str[source]

Create a str representation of a module.

NDRepr.repr_dict_keys(obj: KeysView[Any], level: int) str[source]

Create a str representation of a KeysView.

NDRepr.repr_dict_values(obj: ValuesView[Any], level: int) str[source]

Create a str representation of a ValuesView.

NDRepr.repr_dict_items(obj: ItemsView[Any, Any], level: int) str[source]

Create a str representation of a ItemsView.

NDRepr.repr_Molecule(obj: scm.plams.mol.molecule.Molecule, level: int) str[source]

Create a str representation of a plams.Molecule instance.

NDRepr.repr_Settings(obj: scm.plams.core.settings.Settings, level: int) str[source]

Create a str representation of a plams.Settings instance.

NDRepr.repr_Atom(obj: scm.plams.mol.molecule.Atom, level: int) str[source]

Create a str representation of a plams.Atom instance.

NDRepr.repr_Bond(obj: scm.plams.mol.molecule.Bond, level: int) str[source]

Create a str representation of a plams.Bond instance.

NDRepr.repr_ndarray(obj: ndarray[Any, Any], level: int) str[source]

Create a str representation of a numpy.ndarray instance.

NDRepr.repr_DataFrame(obj: pandas.core.frame.DataFrame, level: int) str[source]

Create a str representation of a pandas.DataFrame instance.

NDRepr.repr_Series(obj: pandas.core.series.Series, level: int) str[source]

Create a str representation of a pandas.Series instance.

NDRepr.repr_Dataset(obj: h5py._h1.dataset.Dataset, level: int) str[source]

Create a str representation of a h5py.Dataset instance.