mhostetter / galois

A performant NumPy extension for Galois fields and their applications
https://mhostetter.github.io/galois/
MIT License
321 stars 29 forks source link

`bch.detect` returns inverse of what it's supposed to #498

Closed erichaydel closed 1 year ago

erichaydel commented 1 year ago

Example code:

import galois
import numpy as np

bch = galois.BCH(31, 21)

valid_codeword = bch.encode(np.zeros([1, 21], dtype=np.uint8))

print(bch.detect(valid_codeword))

# Flip a bit
invalid_codeword = valid_codeword
invalid_codeword[0][0] ^= 1

print(bch.detect(invalid_codeword))
> [False]
> [True]
mhostetter commented 1 year ago

My original conception of the API was for BCH.detect() to "detect errors". So bch.detect(valid_codeword) == False has detected no errors and bch.detect(invalid_codeword) == True has detected at least one error. So I think it's correct as intended.

I'm open to other ideas for a more clear API, though.

erichaydel commented 1 year ago

Ah I was thinking it meant "detect valid codeword". Yeah this is OBE then