Term¶
- class zixy.container.terms.Term(data: TermData[ImplT, SpecT, CoeffT], indexer: int | None = None)[source]¶
Bases:
ViewableItem[TermData[ImplT,SpecT,CoeffT]],Generic[ImplT,SpecT,CoeffT],StringRepresentableA term consisting of a component and a coefficient.
A single term consisting of a component and a coefficient that may be an owning instance referencing the sole element in an owned
TermDatainstance, or a view on an element in another collection.- __init__(data: TermData[ImplT, SpecT, CoeffT], indexer: int | None = None)[source]¶
Initialize the term.
- Parameters:
data – Raw term data object, of which
selfviews one.indexer – Index of the term within
datathatselfviews.
- aliases(other: Term[Any, Any, Any]) bool[source]¶
Determine whether
selfis a view of the same component asother.
- clear() None[source]¶
Set the value of the component to zero and the coefficient to unity.
Note
This method operates in-place.
- property coeff: CoeffT¶
Get a copy of the coefficient of
self.
- classmethod from_cmpnt_coeff(cmpnt: Cmpnt[ImplT, SpecT], coeff: CoeffT) Self[source]¶
Factory to make an instance of
clsfrom a component and a coefficient.- Parameters:
cmpnt – Component to copy from.
coeff – Coefficient scaling the
cmpntin the new instance.
- Returns:
An instance of
clswith the given component and coefficient.
- classmethod from_str(source: str, *args: Any, **kwargs: Any) Self[source]¶
Create an instance of
clsfrom a string.- Parameters:
source – String to parse.
*args – Positional arguments to forward to the component constructor.
**kwargs – Keyword arguments to forward to the component constructor.
- Returns:
An instance of
clsparsed fromsource.
- into(t: type[OutT]) OutT¶
Clone
selfinto a new related container of typet.- Parameters:
t – Type of the new container to create.
- Returns:
A new instance of
tcontaining the same data asself.
- classmethod parse(source: str) Self¶
Parse a string into an instance of
cls.- Deprecated:
use
from_str()instead.
- Parameters:
source – String to parse.
- Returns:
An instance of
clsparsed fromsource.