From 8ae643126e220528af51bd9a89d0f47a14319469 Mon Sep 17 00:00:00 2001 From: relikd Date: Sat, 13 Feb 2021 22:24:17 +0100 Subject: [PATCH] fix few small things --- LP/Probability.py | 2 +- LP/RuneText.py | 2 +- probability.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LP/Probability.py b/LP/Probability.py index 4d70c98..29e52b4 100755 --- a/LP/Probability.py +++ b/LP/Probability.py @@ -28,7 +28,7 @@ class Probability(object): self.prob = [0] * 29 for r in numstream: self.prob[r] += 1 - self.N = len(numstream) + self.N = sum(self.prob) def IC(self): X = sum(x * (x - 1) for x in self.prob) diff --git a/LP/RuneText.py b/LP/RuneText.py index 7a52e21..66b1414 100755 --- a/LP/RuneText.py +++ b/LP/RuneText.py @@ -92,7 +92,7 @@ class RuneText(object): def __invert__(self): return RuneText([~x for x in self._data]) - def __str__(self): + def __repr__(self): return f'RuneText<{len(self)}>' @property diff --git a/probability.py b/probability.py index 1085b8e..cbb737b 100755 --- a/probability.py +++ b/probability.py @@ -39,7 +39,7 @@ def break_cipher(fname, candidates, solver, key_fn): outfmt = 'IoC: {}, interrupt: {}, count: {}, solver: {}' for irp_count, score, irp, kl, skips in candidates: - stops, upto = db_i.consider(fname, irp, irp_count) + stops, upto = db_i.consider(fname, 28 - irp if INVERT else irp, irp_count) print(outfmt.format(score, LP.RUNES[irp], len(stops), key_fn.__name__)) testcase = data[:upto] for x in reversed(skips):