Skip to content

Commit

Permalink
Decoder return -1 for conflicted observation
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkjo committed Jan 30, 2022
1 parent 0f1a685 commit 20d0b87
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions freebarcodes/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ def build_codebook_from_random_codewords(self, codewords, max_err_decode, max_er
if self._codebook[seq_idx] != 0 and self._codebook[seq_idx] != cw_idx:
self._codebook[seq_idx] = reject_idx

# Finally, set rejected idxs to zero for downstream processing
self._codebook[self._codebook == reject_idx] = 0


def analyze_random_codeword_codebook(self):
Expand Down Expand Up @@ -188,9 +186,10 @@ def decode(self, seq):
cw_idx = self._codebook[seq_idx]
if cw_idx == 0:
return
else:
cw_idx -= 1
return self._codewords[cw_idx]
cw_idx -= 1
if cw_idx == len(self._codewords):
return -1
return self._codewords[cw_idx]


def time_decoder(self, n_decodes=1000):
Expand Down

0 comments on commit 20d0b87

Please sign in to comment.