Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
updated the initialization using iter
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitdm committed Apr 16, 2016
1 parent 170b3fc commit 9fcf54d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/sage/coding/linear_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4516,15 +4516,14 @@ def decode_to_code(self, r):
sage: D.decode_to_code(w_err)
(1, 1, 0, 0, 1, 1, 0)
"""
It = iter(self.code.list())
c_min = It.next()
c_min = self.code().zero()
h_min = r.hamming_weight()
try:
for c in self.code():
if (c-r).hamming_weight() < h_min:
h_min = (c-r).hamming_weight()
c_min = c
except:
except StopIteration:
pass
c_min.set_immutable()
return c_min
Expand Down

0 comments on commit 9fcf54d

Please sign in to comment.