From 9ef436543bfb854f394f3ec29177fbfe090d37cd Mon Sep 17 00:00:00 2001 From: Ludo Pulles Date: Tue, 29 Oct 2024 11:51:42 +0100 Subject: [PATCH] Output sparse ternary differently. --- estimator/nd.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/estimator/nd.py b/estimator/nd.py index 10d74d0..30f05c2 100644 --- a/estimator/nd.py +++ b/estimator/nd.py @@ -510,6 +510,23 @@ def support_size(self, fraction=1.0): n, p, m = len(self), self.p, self.m return ceil(binomial(n, p) * binomial(n - p, m) * RR(fraction)) + def __str__(self): + """ + EXAMPLE:: + + >>> from estimator import * + >>> ND.SparseTernary(20, 20, n=100) + T(p=20, m=20, n=100) + + """ + if self.n: + return f"T(p={self.p}, m={self.m}, n={int(self.n)})" + else: + return f"T(p={int(self.p)}, m={int(self.m)})" + + def __repr__(self): + return str(self) + def SparseBinary(hw, n=None): """