diff options
author | Nao Pross <np@0hm.ch> | 2024-03-02 18:45:05 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-02 18:45:05 +0100 |
commit | a3231e35371fc4950965a624289880005374004f (patch) | |
tree | 9cdc4ec5c2e7d5e2de21dadadb04f3ac9675789a | |
parent | Rename Repr.zero_smaller_than to Repr.zero_out_small (diff) | |
download | mdpoly-a3231e35371fc4950965a624289880005374004f.tar.gz mdpoly-a3231e35371fc4950965a624289880005374004f.zip |
Implement missing abstract method Sparse.set_zero
-rw-r--r-- | mdpoly/representations.py | 6 |
1 files changed, 6 insertions, 0 deletions
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() |