From f567d4dcc2c3f9006c2ef54072efbcf2ed39126e Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 22 Apr 2019 17:03:23 +0100 Subject: [PATCH] reduce LFSR2.__init__ by another 2 lines --- TLB/src/LFSR2.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/TLB/src/LFSR2.py b/TLB/src/LFSR2.py index 814ad06f..4a44dfdf 100644 --- a/TLB/src/LFSR2.py +++ b/TLB/src/LFSR2.py @@ -8,12 +8,10 @@ class LFSRPolynomial(set): """ implements a polynomial for use in LFSR """ def __init__(self, exponents=()): - exponents = set(exponents) - exponents.add(0) # must contain zero for e in exponents: assert isinstance(e, int), TypeError("%s must be an int" % repr(e)) assert (e >= 0), ValueError("%d must not be negative" % e) - set.__init__(self, exponents) + set.__init__(self, set(exponents).union({0})) # must contain zero @property def max_exponent(self): @@ -21,7 +19,7 @@ class LFSRPolynomial(set): @property def exponents(self): - exponents = list(self) # get elements of set + exponents = list(self) # get elements of set as a list exponents.sort(reverse=True) return exponents -- 2.30.2