@@ -1004,7 +1004,7 @@ cdef class BinaryCode:
1004
1004
[10101010]
1005
1005
"""
1006
1006
cdef int i, j
1007
- s = ' Binary [%d ,%d ] linear code, generator matrix\n ' % (self .ncols, self .nrows)
1007
+ s = ' Binary [%d ,%d ] linear code, generator matrix\n ' % (self .ncols, self .nrows)
1008
1008
for i from 0 <= i < self .nrows:
1009
1009
s += ' [' + self ._word((< codeword> 1 )<< i) + ' ]\n '
1010
1010
return s
@@ -1028,10 +1028,8 @@ cdef class BinaryCode:
1028
1028
Note that behavior under input which does not represent a word in
1029
1029
the code is unspecified (gives nonsense).
1030
1030
"""
1031
- s = ' '
1032
- for j from 0 <= j < self .ncols:
1033
- s += ' %d ' % self .is_one(coords,j)
1034
- return s
1031
+ return ' ' .join(' %d ' % self .is_one(coords, j)
1032
+ for j in range (self .ncols))
1035
1033
1036
1034
def _is_one (self , word , col ):
1037
1035
"""
@@ -1186,7 +1184,8 @@ cdef class BinaryCode:
1186
1184
if not parity:
1187
1185
while not combination & (1 << j): j += 1
1188
1186
j += 1
1189
- if j == self .nrows: break
1187
+ if j == self .nrows:
1188
+ break
1190
1189
else :
1191
1190
combination ^= (1 << j)
1192
1191
word ^= self .basis[j]
@@ -1309,22 +1308,23 @@ cdef class OrbitPartition:
1309
1308
"""
1310
1309
cdef int i
1311
1310
cdef int j
1312
- s = ' OrbitPartition on %d words and %d columns. Data:\n ' % (self .nwords, self .ncols)
1311
+ s = ' OrbitPartition on %d words and %d columns. Data:\n ' % (self .nwords,
1312
+ self .ncols)
1313
1313
# s += 'Parents::\n'
1314
1314
s += ' Words:\n '
1315
1315
for i from 0 <= i < self .nwords:
1316
- s += ' %d ,' % self .wd_parent[i]
1316
+ s += ' %d ,' % self .wd_parent[i]
1317
1317
s = s[:- 1 ] + ' \n Columns:\n '
1318
1318
for j from 0 <= j < self .ncols:
1319
- s += ' %d ,' % self .col_parent[j]
1319
+ s += ' %d ,' % self .col_parent[j]
1320
1320
# s = s[:-1] + '\n'
1321
1321
# s += 'Min Cell Reps::\n'
1322
1322
# s += 'Words:\n'
1323
1323
# for i from 0 <= i < self.nwords:
1324
- # s += '%d,'% self.wd_min_cell_rep[i]
1324
+ # s += '%d,' % self.wd_min_cell_rep[i]
1325
1325
# s = s[:-1] + '\nColumns:\n'
1326
1326
# for j from 0 <= j < self.ncols:
1327
- # s += '%d,'% self.col_min_cell_rep[j]
1327
+ # s += '%d,' % self.col_min_cell_rep[j]
1328
1328
return s[:- 1 ]
1329
1329
1330
1330
def _wd_find (self , word ):
@@ -1773,7 +1773,8 @@ cdef class PartitionStack:
1773
1773
current = ' '
1774
1774
for k from 0 <= k < 2 * self .ncols:
1775
1775
current = self ._repr_at_k(k)
1776
- if current == last: break
1776
+ if current == last:
1777
+ break
1777
1778
s += current
1778
1779
last = current
1779
1780
return s
@@ -1985,7 +1986,7 @@ cdef class PartitionStack:
1985
1986
cdef int reps = (1 << self_col_ents[0 ]), length, word
1986
1987
cdef int radix = self .radix, nwords = self .nwords, ncols = self .ncols
1987
1988
length = 1 + nwords/ radix
1988
- if nwords% radix:
1989
+ if nwords % radix:
1989
1990
length += 1
1990
1991
for i from 0 <= i < length:
1991
1992
Omega[start+ i] = 0
@@ -1995,7 +1996,7 @@ cdef class PartitionStack:
1995
1996
for i from 0 < i < nwords:
1996
1997
if self_wd_lvls[i- 1 ] <= k:
1997
1998
word = self_wd_lvls[i- 1 ]
1998
- Omega[start+ 1 + word/ radix] += (1 << word% radix)
1999
+ Omega[start+ 1 + word/ radix] += (1 << word % radix)
1999
2000
2000
2001
# def _fixed_cols(self, mcrs, k): #TODO
2001
2002
# """
@@ -2048,13 +2049,13 @@ cdef class PartitionStack:
2048
2049
Phi[start] = fixed & Omega[start]
2049
2050
# zero out the rest of Phi
2050
2051
length = 1 + nwords/ self .radix
2051
- if nwords% self .radix:
2052
+ if nwords % self .radix:
2052
2053
length += 1
2053
2054
for i from 0 < i < length:
2054
2055
Phi[start+ i] = 0
2055
2056
for i from 0 <= i < nwords:
2056
2057
ell = self_wd_ents[i]
2057
- Phi[start+ 1 + ell/ radix] = ((self_wd_lvls[i] <= k) << ell% radix)
2058
+ Phi[start+ 1 + ell/ radix] = ((self_wd_lvls[i] <= k) << ell % radix)
2058
2059
for i from 0 < i < length:
2059
2060
Phi[i] &= Omega[i]
2060
2061
@@ -2125,7 +2126,8 @@ cdef class PartitionStack:
2125
2126
min = i - j + 1
2126
2127
location = j
2127
2128
j = i + 1
2128
- if self_col_lvls[i] == - 1 : break
2129
+ if self_col_lvls[i] == - 1 :
2130
+ break
2129
2131
i += 1
2130
2132
# i = 0; j = 0
2131
2133
# while True:
@@ -2142,13 +2144,14 @@ cdef class PartitionStack:
2142
2144
j = location
2143
2145
# zero out this level of W:
2144
2146
ell = 1 + nwords/ radix
2145
- if nwords% radix:
2147
+ if nwords % radix:
2146
2148
ell += 1
2147
2149
for i from 0 <= i < ell:
2148
2150
W[start+ i] = 0
2149
2151
if min_is_col:
2150
2152
while True :
2151
- if self_col_lvls[j] <= k: break
2153
+ if self_col_lvls[j] <= k:
2154
+ break
2152
2155
j += 1
2153
2156
# j now points to the last element of the cell
2154
2157
i = location
@@ -2158,13 +2161,14 @@ cdef class PartitionStack:
2158
2161
return self_col_ents[location]
2159
2162
else :
2160
2163
while True :
2161
- if self_wd_lvls[j] <= k: break
2164
+ if self_wd_lvls[j] <= k:
2165
+ break
2162
2166
j += 1
2163
2167
# j now points to the last element of the cell
2164
2168
i = location
2165
2169
while i <= j:
2166
2170
ell = self_wd_ents[i]
2167
- W[start+ 1 + ell/ radix] ^= (1 << ell% radix)
2171
+ W[start+ 1 + ell/ radix] ^= (1 << ell % radix)
2168
2172
i += 1
2169
2173
return self_wd_ents[location] ^ self .flag
2170
2174
@@ -3492,9 +3496,9 @@ cdef class BinaryCodeClassifier:
3492
3496
for i from 0 <= i < jj:
3493
3497
Omega[ii+ i] = ~ 0
3494
3498
Phi[ii+ i] = 0
3495
- if nwords% self .radix:
3499
+ if nwords % self .radix:
3496
3500
jj += 1
3497
- # Omega[ii+jj-1] = ~((1 << nwords% self.radix) - 1)
3501
+ # Omega[ii+jj-1] = ~((1 << nwords % self.radix) - 1)
3498
3502
# Omega stores the minimum cell representatives
3499
3503
i = 0
3500
3504
while i < ncols:
@@ -3510,18 +3514,18 @@ cdef class BinaryCodeClassifier:
3510
3514
while i < nwords:
3511
3515
j = word_gamma[i]
3512
3516
while j != i:
3513
- Omega[ii+ 1 + j/ jj] ^= (1 << (j% jj))
3517
+ Omega[ii+ 1 + j/ jj] ^= (1 << (j % jj))
3514
3518
j = word_gamma[j]
3515
3519
i += 1
3516
- while i < nwords and not Omega[ii+ 1 + i/ jj]& (1 << (i% jj)):
3520
+ while i < nwords and not Omega[ii+ 1 + i/ jj]& (1 << (i % jj)):
3517
3521
i += 1
3518
3522
# Phi stores the columns fixed by the automorphism
3519
3523
for i from 0 <= i < ncols:
3520
3524
if col_gamma[i] == i:
3521
3525
Phi[ii] ^= (1 << i)
3522
3526
for i from 0 <= i < nwords:
3523
3527
if word_gamma[i] == i:
3524
- Phi[ii+ 1 + i/ jj] ^= (1 << (i% jj))
3528
+ Phi[ii+ 1 + i/ jj] ^= (1 << (i % jj))
3525
3529
3526
3530
# Now incorporate the automorphism into Theta
3527
3531
j = Theta.merge_perm(col_gamma, word_gamma)
@@ -3571,7 +3575,7 @@ cdef class BinaryCodeClassifier:
3571
3575
ii = self .Phi_size* l
3572
3576
jj = self .Phi_size* k
3573
3577
j = 1 + nwords/ self .radix
3574
- if nwords% self .radix:
3578
+ if nwords % self .radix:
3575
3579
j += 1
3576
3580
W[jj] &= Omega[ii]
3577
3581
for i from 0 < i < j:
@@ -3623,7 +3627,7 @@ cdef class BinaryCodeClassifier:
3623
3627
if v[k]& nu.flag:
3624
3628
ii = self .radix
3625
3629
i = (v[k]^ nu.flag) + 1
3626
- while i < nwords and not (1 << i% ii) & W[jj+ 1 + i/ ii]:
3630
+ while i < nwords and not (1 << i % ii) & W[jj+ 1 + i/ ii]:
3627
3631
i += 1
3628
3632
if i < nwords:
3629
3633
v[k] = i^ nu.flag
@@ -3695,14 +3699,14 @@ cdef class BinaryCodeClassifier:
3695
3699
# intersect W[k] with each Omega[i] such that v[0]...v[k-1] is in Phi[i]
3696
3700
jj = self .Phi_size* self .L
3697
3701
iii = nwords/ self .radix
3698
- if nwords% self .radix:
3702
+ if nwords % self .radix:
3699
3703
iii += 1
3700
3704
for ii from 0 <= ii < iii:
3701
3705
Phi[jj+ ii] = 0
3702
3706
for ii from 0 <= ii < k:
3703
3707
if v[ii]& nu.flag:
3704
3708
i = v[ii]^ nu.flag
3705
- Phi[jj+ 1 + i/ self .radix] ^= (1 << i% self .radix)
3709
+ Phi[jj+ 1 + i/ self .radix] ^= (1 << i % self .radix)
3706
3710
else :
3707
3711
Phi[jj] ^= (1 << v[ii])
3708
3712
for i from 0 <= i <= l:
@@ -3722,7 +3726,7 @@ cdef class BinaryCodeClassifier:
3722
3726
i = (v[k]^ nu.flag)
3723
3727
while i < nwords:
3724
3728
i += 1
3725
- if (1 << i% self .radix) & W[jjj+ 1 + i/ self .radix]: break
3729
+ if (1 << i % self .radix) & W[jjj+ 1 + i/ self .radix]: break
3726
3730
if i < nwords:
3727
3731
v[k] = i^ nu.flag
3728
3732
state = 15
@@ -3852,9 +3856,9 @@ cdef class BinaryCodeClassifier:
3852
3856
sage: soc_iter = codes.databases.self_orthogonal_binary_codes(12, 6, 4)
3853
3857
sage: L = list(soc_iter)
3854
3858
sage: for n in range(13):
3855
- ....: s = 'n=%2d : '% n
3859
+ ....: s = 'n=%2d : ' % n
3856
3860
....: for k in range(1,7):
3857
- ....: s += '%3d '% le n([C for C in L
3861
+ ....: s += '%3d ' % le n([C for C in L
3858
3862
....: if C.length() == n and C.dimension() == k])
3859
3863
....: print(s)
3860
3864
n= 0 : 0 0 0 0 0 0
@@ -3972,7 +3976,7 @@ cdef class BinaryCodeClassifier:
3972
3976
3973
3977
while True :
3974
3978
if nonzero_gate & word == nonzero_gate and \
3975
- (ham_wts[word & 65535 ] + ham_wts[(word >> 16 ) & 65535 ])% d == 0 :
3979
+ (ham_wts[word & 65535 ] + ham_wts[(word >> 16 ) & 65535 ]) % d == 0 :
3976
3980
temp = (word >> B.nrows) & ((< codeword> 1 << k) - 1 )
3977
3981
if not orbit_checks[temp >> log_2_radix] & ((< codeword> 1 ) << (temp & radix_gate)):
3978
3982
B_aug = BinaryCode(B, word)
0 commit comments