Skip to content

Commit 11b2ef5

Browse files
committed
some pep8 fixes in coding, in particular E275
1 parent 0c390a0 commit 11b2ef5

File tree

8 files changed

+89
-89
lines changed

8 files changed

+89
-89
lines changed

src/sage/coding/abstract_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _explain_constructor(cl):
128128
var = "It accepts unspecified arguments as well.\n"
129129
else:
130130
var = ""
131-
return("{}\n{}\n{}See the documentation of {}.{} for more details."
131+
return ("{}\n{}\n{}See the documentation of {}.{} for more details."
132132
.format(reqs, opts, var, cl.__module__, cl.__name__))
133133

134134

src/sage/coding/code_bounds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _check_n_q_d(n, q, d, field_based=True):
221221
raise ValueError("The alphabet size must be an integer >1")
222222
if field_based and not is_prime_power(q):
223223
raise ValueError("The alphabet size does not make sense for a code over a field")
224-
if not(0 < d <= n and n in ZZ and d in ZZ):
224+
if not (0 < d <= n and n in ZZ and d in ZZ):
225225
raise ValueError("The length or minimum distance does not make sense")
226226
return True
227227

src/sage/coding/cyclic_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ def field_embedding(self):
577577
To: Finite Field in z3 of size 2^3
578578
Defn: 1 |--> 1
579579
"""
580-
if not(hasattr(self, "_field_embedding")):
580+
if not (hasattr(self, "_field_embedding")):
581581
self.defining_set()
582582
return self._field_embedding
583583

src/sage/coding/grs_code.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ def __eq__(self, other):
258258
True
259259
"""
260260
return isinstance(other, GeneralizedReedSolomonCode) \
261-
and self.base_field() == other.base_field() \
262-
and self.length() == other.length() \
263-
and self.dimension() == other.dimension() \
264-
and self.evaluation_points() == other.evaluation_points() \
265-
and self.column_multipliers() == other.column_multipliers()
261+
and self.base_field() == other.base_field() \
262+
and self.length() == other.length() \
263+
and self.dimension() == other.dimension() \
264+
and self.evaluation_points() == other.evaluation_points() \
265+
and self.column_multipliers() == other.column_multipliers()
266266

267267
def __hash__(self):
268268
"""
@@ -298,9 +298,9 @@ def _repr_(self):
298298
[40, 12, 29] Generalized Reed-Solomon Code over GF(59)
299299
"""
300300
return "[%s, %s, %s] %sReed-Solomon Code over GF(%s)"\
301-
% (self.length(), self.dimension(), self.minimum_distance(),
302-
"Generalized " if self.is_generalized() else "",
303-
self.base_field().cardinality())
301+
% (self.length(), self.dimension(), self.minimum_distance(),
302+
"Generalized " if self.is_generalized() else "",
303+
self.base_field().cardinality())
304304

305305
def _latex_(self):
306306
r"""
@@ -319,9 +319,9 @@ def _latex_(self):
319319
[40, 12, 29] \textnormal{ Generalized Reed-Solomon Code over } \Bold{F}_{59}
320320
"""
321321
return "[%s, %s, %s] \\textnormal{ %sReed-Solomon Code over } %s"\
322-
% (self.length(), self.dimension(), self.minimum_distance(),
323-
"Generalized " if self.is_generalized() else "",
324-
self.base_field()._latex_())
322+
% (self.length(), self.dimension(), self.minimum_distance(),
323+
"Generalized " if self.is_generalized() else "",
324+
self.base_field()._latex_())
325325

326326
def minimum_distance(self):
327327
r"""
@@ -390,7 +390,7 @@ def is_generalized(self):
390390
sage: C2.is_generalized()
391391
True
392392
"""
393-
return not all( beta.is_one() for beta in self.column_multipliers() )
393+
return not all(beta.is_one() for beta in self.column_multipliers())
394394

395395
@cached_method
396396
def multipliers_product(self):
@@ -538,7 +538,7 @@ def weight_distribution(self):
538538
q = self.base_ring().order()
539539
s = SR.var('s')
540540
wd = [1] + [0] * (d - 1)
541-
for i in range(d, n+1):
541+
for i in range(d, n + 1):
542542
tmp = binomial(n, i) * (q - 1)
543543
wd.append(tmp * symbolic_sum(binomial(i-1, s) * (-1)**s * q**(i - d - s), s, 0, i-d))
544544
return wd
@@ -647,9 +647,9 @@ def ReedSolomonCode(base_field, length, dimension, primitive_root=None):
647647
else:
648648
if primitive_root.multiplicative_order() != length:
649649
raise ValueError("Supplied primitive_root is not a primitive n'th root of unity")
650-
return GeneralizedReedSolomonCode([ primitive_root**i for i in range(length) ], dimension)
650+
return GeneralizedReedSolomonCode([primitive_root**i for i in range(length)], dimension)
651651

652-
####################### encoders ###############################
652+
# ###################### encoders ###############################
653653

654654

655655
class GRSEvaluationVectorEncoder(Encoder):
@@ -723,7 +723,7 @@ def __eq__(self, other):
723723
False
724724
"""
725725
return isinstance(other, GRSEvaluationVectorEncoder) \
726-
and self.code() == other.code()
726+
and self.code() == other.code()
727727

728728
def _repr_(self):
729729
r"""
@@ -788,7 +788,7 @@ def generator_matrix(self):
788788
C = self.code()
789789
alphas = C.evaluation_points()
790790
col_mults = C.column_multipliers()
791-
g = matrix(C.base_field(), C.dimension(), C.length(), lambda i,j: col_mults[j] * alphas[j]**i)
791+
g = matrix(C.base_field(), C.dimension(), C.length(), lambda i, j: col_mults[j] * alphas[j]**i)
792792
g.set_immutable()
793793
return g
794794

@@ -1086,7 +1086,7 @@ def message_space(self):
10861086
polynomial_ring = message_space
10871087

10881088

1089-
####################### decoders ###############################
1089+
# ###################### decoders ###############################
10901090

10911091

10921092
class GRSBerlekampWelchDecoder(Decoder):
@@ -1184,7 +1184,7 @@ def _latex_(self):
11841184
\textnormal{ Reed-Solomon Code over } \Bold{F}_{59}
11851185
"""
11861186
return "\\textnormal{Berlekamp Welch decoder for }%s"\
1187-
% self.code()._latex_()
1187+
% self.code()._latex_()
11881188

11891189
def _decode_to_code_and_message(self, r):
11901190
r"""
@@ -1235,8 +1235,8 @@ def _decode_to_code_and_message(self, r):
12351235
l0 = n-1-t
12361236
l1 = n-1-t-(k-1)
12371237
S = matrix(C.base_field(), n, l0+l1+2,
1238-
lambda i, j: (C.evaluation_points()[i])**j if j < (l0+1)
1239-
else r_list[i]*(C.evaluation_points()[i])**(j-(l0+1)))
1238+
lambda i, j: (C.evaluation_points()[i])**j if j < (l0+1)
1239+
else r_list[i]*(C.evaluation_points()[i])**(j-(l0+1)))
12401240
S = S.right_kernel()
12411241
S = S.basis_matrix().row(0)
12421242
R = C.base_field()['x']
@@ -1574,7 +1574,7 @@ def _partial_xgcd(self, a, b, PolRing):
15741574

15751575
r = b
15761576
prev_r = a
1577-
while(r.degree() >= stop):
1577+
while (r.degree() >= stop):
15781578
q = prev_r.quo_rem(r)[0]
15791579
(prev_r, r) = (r, prev_r - q * r)
15801580
(prev_s, s) = (s, prev_s - q * s)
@@ -1858,9 +1858,9 @@ def __eq__(self, other):
18581858
False
18591859
"""
18601860
return isinstance(other, GRSErrorErasureDecoder) \
1861-
and self.code() == other.code()
1861+
and self.code() == other.code()
18621862

1863-
def _repr_(self):
1863+
def _repr_(self) -> str:
18641864
r"""
18651865
Return a string representation of ``self``.
18661866
@@ -1890,7 +1890,7 @@ def _latex_(self):
18901890
\textnormal{ Reed-Solomon Code over } \Bold{F}_{59}
18911891
"""
18921892
return "\\textnormal{Error-Erasure decoder for }%s"\
1893-
% self.code()._latex_()
1893+
% self.code()._latex_()
18941894

18951895
def decode_to_message(self, word_and_erasure_vector):
18961896
r"""
@@ -2095,8 +2095,8 @@ def __eq__(self, other):
20952095
False
20962096
"""
20972097
return isinstance(other, GRSKeyEquationSyndromeDecoder) \
2098-
and self.code() == other.code()\
2099-
and self.input_space() == other.input_space()
2098+
and self.code() == other.code()\
2099+
and self.input_space() == other.input_space()
21002100

21012101
def _repr_(self):
21022102
r"""
@@ -2165,7 +2165,7 @@ def _partial_xgcd(self, a, b, PolRing):
21652165
prev_r = a
21662166
r = b
21672167

2168-
while(r.degree() >= t.degree()):
2168+
while (r.degree() >= t.degree()):
21692169
q = prev_r.quo_rem(r)[0]
21702170
prev_r, r = r, prev_r - q * r
21712171
prev_t, t = t, prev_t - q * t
@@ -2376,10 +2376,10 @@ def decoding_radius(self):
23762376
sage: D.decoding_radius()
23772377
14
23782378
"""
2379-
return (self.code().minimum_distance()-1) // 2
2379+
return (self.code().minimum_distance() - 1) // 2
23802380

23812381

2382-
####################### registration ###############################
2382+
# ###################### registration ###############################
23832383

23842384
GeneralizedReedSolomonCode._registered_encoders["EvaluationVector"] = GRSEvaluationVectorEncoder
23852385
GeneralizedReedSolomonCode._registered_encoders["EvaluationPolynomial"] = GRSEvaluationPolynomialEncoder

0 commit comments

Comments
 (0)