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:
Convention for boolean masks. |
|
Alias for simple |
|
Signature for phases_factory function. |
|
Signature for tag_phases function. |
Classes:
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
- 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)