Skip to content

Commit 481d642

Browse files
committed
suggested fixes done
1 parent 29ecd91 commit 481d642

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

src/sage/coding/binary_code.pyx

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def weight_dist(M):
131131
bitset_zero(&basis[i])
132132
for j in M.row(i).nonzero_positions():
133133
bitset_set(&basis[i], j)
134-
for i from 0 <= i < deg+1:
134+
for i in range(deg + 1):
135135
LL[i] = 0
136136
bitset_init(word, deg)
137137
bitset_zero(word)
@@ -147,9 +147,8 @@ def weight_dist(M):
147147
k += 1
148148
if k == dim:
149149
break
150-
else:
151-
j ^= (1 << k)
152-
bitset_xor(word, word, &basis[k])
150+
j ^= (1 << k)
151+
bitset_xor(word, word, &basis[k])
153152
bitset_free(word)
154153
L = [int(LL[i]) for i from 0 <= i < deg+1]
155154
for i from 0 <= i < dim:
@@ -329,9 +328,8 @@ cdef WordPermutation *create_word_perm(object list_perm) noexcept:
329328
j += 1
330329
if j == chunk_size:
331330
break
332-
else:
333-
comb ^= (1 << j)
334-
image ^= images_i[1 << j]
331+
comb ^= (1 << j)
332+
image ^= images_i[1 << j]
335333
return word_perm
336334

337335
cdef WordPermutation *create_array_word_perm(int *array, int start, int degree) noexcept:
@@ -380,9 +378,8 @@ cdef WordPermutation *create_array_word_perm(int *array, int start, int degree)
380378
j += 1
381379
if j == chunk_size:
382380
break
383-
else:
384-
comb ^= (1 << j)
385-
image ^= images_i[1 << j]
381+
comb ^= (1 << j)
382+
image ^= images_i[1 << j]
386383
return word_perm
387384

388385
cdef WordPermutation *create_id_word_perm(int degree) noexcept:
@@ -430,9 +427,8 @@ cdef WordPermutation *create_id_word_perm(int degree) noexcept:
430427
j += 1
431428
if j == chunk_size:
432429
break
433-
else:
434-
comb ^= (1 << j)
435-
image ^= images_i[1 << j]
430+
comb ^= (1 << j)
431+
image ^= images_i[1 << j]
436432
return word_perm
437433

438434
cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation *h) noexcept:
@@ -465,7 +461,7 @@ cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation
465461
sig_free(word_perm)
466462
raise RuntimeError("Error allocating memory.")
467463
word_perm.images[i] = images_i
468-
for j from 0 <= j < chunk_size:
464+
for j in range(chunk_size):
469465
image = (<codeword>1) << (chunk_size*i + j)
470466
image = permute_word_by_wp(h, image)
471467
image = permute_word_by_wp(g, image)
@@ -483,9 +479,8 @@ cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation
483479
j += 1
484480
if j == chunk_size:
485481
break
486-
else:
487-
comb ^= (1 << j)
488-
image ^= images_i[1 << j]
482+
comb ^= (1 << j)
483+
image ^= images_i[1 << j]
489484
return word_perm
490485

491486
cdef WordPermutation *create_inv_word_perm(WordPermutation *g) noexcept:
@@ -2008,12 +2003,12 @@ cdef class PartitionStack:
20082003
length = 1 + nwords/radix
20092004
if nwords % radix:
20102005
length += 1
2011-
for i from 0 <= i < length:
2006+
for i in range(length):
20122007
Omega[start+i] = 0
2013-
for i in range(ncols):
2008+
for i in range(1, ncols):
20142009
Omega[start] += ((self_col_lvls[i-1] <= k) << self_col_ents[i])
20152010
Omega[start+1] = (1 << self_wd_ents[0])
2016-
for i in range(nwords):
2011+
for i in range(1, nwords):
20172012
if self_wd_lvls[i-1] <= k:
20182013
word = self_wd_lvls[i-1]
20192014
Omega[start+1+word/radix] += (1 << word % radix)
@@ -2873,7 +2868,7 @@ cdef class PartitionStack:
28732868
0
28742869
"""
28752870
cdef int i, j, l, m, ncols = self.ncols, nwords = self.nwords
2876-
for i in range(nwords):
2871+
for i in range(1, nwords):
28772872
for j in range(ncols):
28782873
l = CG.is_one(self.wd_ents[i], self.col_ents[j])
28792874
m = CG.is_one(other.wd_ents[i], other.col_ents[j])

0 commit comments

Comments
 (0)