From 6b5a940c75ae32b6a127f8b3fb7d2391602b5521 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 2 Mar 2024 12:49:18 +0100 Subject: Improve docstring of index types --- mdpoly/types.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/mdpoly/types.py b/mdpoly/types.py index 14847fa..29e7b83 100644 --- a/mdpoly/types.py +++ b/mdpoly/types.py @@ -50,13 +50,31 @@ class MatrixIndex(NamedTuple): return cls(row, col) -class PolyTermIndex(NamedTuple): - term: int +class PolyVarIndex(NamedTuple): + """ + Tuple to index a power of a variable. + + Concretely this represents things like x^2, y^4 + """ + varindex: int power: Number -class PolyIndex: +class PolyIndex(tuple[PolyVarIndex]): """ Tuple to index a coefficient of a polynomial. + + Example: + + Suppose there are two variables x, y with indices 0, 1 respectively. + Then the monomal xy^2 has PolyIndex + + (PolyVarIndex(varindex=0, power=1), PolyVarIndex(varindex=1, power=2) + + Then given the polynomial + + p(x, y) = 3x^2 + 5xy^2 + + The with the PolyIndex above we can retrieve the coefficient 5 in front + of xy^2. """ - indices: tuple[PolyTermIndex] -- cgit v1.2.1