Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to correct errors with creedsolo (2.1.2b1)? #70

Open
vytas7 opened this issue Jul 21, 2023 · 3 comments
Open

How to correct errors with creedsolo (2.1.2b1)? #70

vytas7 opened this issue Jul 21, 2023 · 3 comments

Comments

@vytas7
Copy link

vytas7 commented Jul 21, 2023

Hello!
I'm having issues with using the cythonized creedsolo, encoding and checking seems to work great, but my attempt to correct errors results in a ReedSolomonError:

FAILED test.py::test_reed_solomon - creedsolo.creedsolo.ReedSolomonError: Too many (or few) errors found by Chien Search for the errata locator polynomial!

(It works as expected with the pure Python version.)

My test case used:

# Pure Python works as expected
# import reedsolo as rs
import creedsolo as rs

DATA = b'123456789abcdef\n' * 64


def test_reed_solomon():
    prim = rs.find_prime_polys(c_exp=11, fast_primes=True, single=True)[0]
    rs.init_tables(c_exp=11, prim=prim)

    gen = rs.rs_generator_poly_all(1024+16)
    encoded = rs.rs_encode_msg(DATA, 16, gen=gen[16])

    encoded[3] = ord('7')
    encoded[100] = ord('!')

    assert not rs.rs_check(encoded, 16)
    _, _, errata_pos = rs.rs_correct_msg(encoded, 16)
    assert set(errata_pos) == {3, 100}

FWIW, I used the current Git master @ 23b8eab

pip install . --config-setting="--build-option=--cythonize"
@lrq3000
Copy link
Collaborator

lrq3000 commented Jul 21, 2023 via email

@vytas7
Copy link
Author

vytas7 commented Jul 21, 2023

Thanks @lrq3000!
No worries, I was just looking for some Reed-Solomon library for a hobby project 🙂 Not urgent at all.

I did use the latest Git master to start with.

Not sure if it is me misunderstanding something, or it is a real bug (related to the recent Cython 3.0.0 release?).

@vytas7 vytas7 changed the title How to correct errors with creedsolo? How to correct errors with creedsolo (2.1.2b1)? Jul 21, 2023
@lrq3000
Copy link
Collaborator

lrq3000 commented Jul 21, 2023

No I meant your issue here was incomplete when I first saw it, only the first sentence appeared ;-)

Ok so creedsolo is more optimized for GF(2⁸). For other fields, it may work, but it may also fail. I’ll have to have a second look, here you are using GF(2^11) so that’s likely why it’s failing.

Please try using the RSCodec class instead of using the low level functions, as this class tries to handles the tricky technicals, and especially with creedsolo, there are more hoops to go through to be compatible with all fields since creedsolo tries to be as optimized as possible, which is at the expense of flexibility and less generalizability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants