Base classes and other methods#

class lnpy.extensions.AccessorMixin[source]#

Bases: object

Mixin for accessor.

Methods:

register_accessor(name, accessor[, ...])

Register a property name to class of type accessor(self)

decorate_accessor(name[, single_create])

Register a property name to class of type accessor(self).

classmethod register_accessor(name, accessor, single_create=False)[source]#

Register a property name to class of type accessor(self)

Examples

>>> class parent(AccessorMixin):
...     pass
>>> class hello(AccessorMixin):
...     def __init__(self, parent):
...         self._parent = parent
...
...     def there(self):
...         return f"{type(self._parent)}"
>>> parent.register_accessor("hello", hello)
>>> x = parent()
>>> x.hello.there()
"<class 'lnpy.extensions.parent'>"
classmethod decorate_accessor(name, single_create=False)[source]#

Register a property name to class of type accessor(self).

Examples

>>> class parent(AccessorMixin):
...     pass
>>> @parent.decorate_accessor("hello")
... class hello(AccessorMixin):
...     def __init__(self, parent):
...         self._parent = parent
...
...     def there(self):
...         return f"{type(self._parent)}"
>>> x = parent()
>>> x.hello.there()
"<class 'lnpy.extensions.parent'>"

Typing definitions for lnpy#

Classes:

EnsembleT

TypeVar for Ensemble.

Data:

MaskConvention

Convention for boolean masks.

NDArrayAny

Alias for simple numpy.typing.NDArray[Any]

PhasesFactorySignature

Signature for phases_factory function.

TagPhasesSignature

Signature for tag_phases function.

class lnpy.core.typing.EnsembleT#

TypeVar for Ensemble.

alias of TypeVar(‘EnsembleT’, GrandCanonicalEnsemble, CanonicalEnsemble)

lnpy.core.typing.MaskConvention = 'Literal["image", "masked"] | bool'#

Convention for boolean masks.

lnpy.core.typing.NDArrayAny(*args, **kwargs)#

Alias for simple numpy.typing.NDArray[Any]

alias of ndarray[tuple[Any, …], dtype[Any]]

lnpy.core.typing.PhasesFactorySignature(self, *args, **kwds)#

Signature for phases_factory function.

alias of Callable[[…], lnpy.lnpiseries.lnPiCollection]

lnpy.core.typing.TagPhasesSignature(self, *args, **kwds)#

Signature for tag_phases function.

alias of Callable[[Sequence[lnpy.lnpidata.lnPiMasked]], Sequence[int] | NDArrayAny]