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#

Data:

MaskConvention

Convention for boolean masks.

MyNDArray

Alias for simple numpy.typing.NDArray

PhasesFactorySignature

Signature for phases_factory function.

TagPhasesSignature

Signature for tag_phases function.

Classes:

T_Ensemble

TypeVar for Ensemble.

lnpy._typing.MaskConvention(*args, **kwargs)#

Convention for boolean masks.

alias of Literal[‘image’, ‘masked’, True, False]

lnpy._typing.MyNDArray(*args, **kwargs)#

Alias for simple numpy.typing.NDArray

alias of ndarray[Any, dtype[Any]]

lnpy._typing.PhasesFactorySignature(*args, **kwargs)#

Signature for phases_factory function.

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

class lnpy._typing.T_Ensemble#

TypeVar for Ensemble.

alias of TypeVar(‘T_Ensemble’, xGrandCanonical, xCanonical)

lnpy._typing.TagPhasesSignature(*args, **kwargs)#

Signature for tag_phases function.

alias of Callable[[Sequence[lnpy.lnpidata.lnPiMasked]], Union[Sequence[int], ndarray[Any, dtype[Any]]]]