From a3231e35371fc4950965a624289880005374004f Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 2 Mar 2024 18:45:05 +0100 Subject: Implement missing abstract method Sparse.set_zero --- mdpoly/representations.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mdpoly/representations.py b/mdpoly/representations.py index 0cda642..55763a9 100644 --- a/mdpoly/representations.py +++ b/mdpoly/representations.py @@ -32,6 +32,12 @@ class SparseRepr(Repr): self.data[entry][term] = value + def set_zero(self, entry: MatrixIndex, term: PolyIndex): + """ Set an entry to zero """ + del self.data[entry][term] + if not self.data[entry]: + del self.data[entry] + def entries(self) -> Sequence[MatrixIndex]: """ Return indices to non-zero entries of the matrix """ yield from self.data.keys() -- cgit v1.2.1