Skip to content

Commit

Permalink
Add unit tests for RS decode with c != 1
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Jan 7, 2022
1 parent 69bae7e commit 3d90c8a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
50 changes: 25 additions & 25 deletions tests/codes/test_rs_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
from .helper import random_errors

CODES = [
(15, 13), # GF(2^4) with t=1
(15, 11), # GF(2^4) with t=2
(15, 9), # GF(2^4) with t=3
(15, 7), # GF(2^4) with t=4
(15, 5), # GF(2^4) with t=5
(15, 3), # GF(2^4) with t=6
(15, 1), # GF(2^4) with t=7
(16, 14), # GF(17) with t=1
(16, 12), # GF(17) with t=2
(16, 10), # GF(17) with t=3
(26, 24), # GF(3^3) with t=1
(26, 22), # GF(3^3) with t=2
(26, 20), # GF(3^3) with t=3
(15, 13, 1), # GF(2^4) with t=1
(15, 11, 2), # GF(2^4) with t=2
(15, 9, 1), # GF(2^4) with t=3
(15, 7, 2), # GF(2^4) with t=4
(15, 5, 1), # GF(2^4) with t=5
(15, 3, 2), # GF(2^4) with t=6
(15, 1, 1), # GF(2^4) with t=7
(16, 14, 2), # GF(17) with t=1
(16, 12, 1), # GF(17) with t=2
(16, 10, 2), # GF(17) with t=3
(26, 24, 1), # GF(3^3) with t=1
(26, 22, 2), # GF(3^3) with t=2
(26, 20, 3), # GF(3^3) with t=3
]


Expand All @@ -48,9 +48,9 @@ def test_exceptions():
class TestSystematic:
@pytest.mark.parametrize("size", CODES)
def test_all_correctable(self, size):
n, k = size[0], size[1]
n, k, c = size[0], size[1], size[2]
N = 100
rs = galois.ReedSolomon(n, k)
rs = galois.ReedSolomon(n, k, c=c)
GF = rs.field
M = GF.Random((N, k))
C = rs.encode(M)
Expand All @@ -77,9 +77,9 @@ def test_all_correctable(self, size):

@pytest.mark.parametrize("size", CODES)
def test_some_uncorrectable(self, size):
n, k = size[0], size[1]
n, k, c = size[0], size[1], size[2]
N = 100
rs = galois.ReedSolomon(n, k)
rs = galois.ReedSolomon(n, k, c=c)
GF = rs.field
M = GF.Random((N, k))
C = rs.encode(M)
Expand Down Expand Up @@ -110,13 +110,13 @@ def test_some_uncorrectable(self, size):
class TestSystematicShortened:
@pytest.mark.parametrize("size", CODES)
def test_all_correctable(self, size):
n, k = size[0], size[1]
n, k, c = size[0], size[1], size[2]
if k == 1:
return
ks = k // 2 # Shorten the code in half
ns = n - (k - ks)
N = 100
rs = galois.ReedSolomon(n, k)
rs = galois.ReedSolomon(n, k, c=c)
GF = rs.field
M = GF.Random((N, ks))
C = rs.encode(M)
Expand All @@ -143,13 +143,13 @@ def test_all_correctable(self, size):

@pytest.mark.parametrize("size", CODES)
def test_some_uncorrectable(self, size):
n, k = size[0], size[1]
n, k, c = size[0], size[1], size[2]
if k == 1:
return
ks = k // 2 # Shorten the code in half
ns = n - (k - ks)
N = 100
rs = galois.ReedSolomon(n, k)
rs = galois.ReedSolomon(n, k, c=c)
GF = rs.field
M = GF.Random((N, ks))
C = rs.encode(M)
Expand Down Expand Up @@ -180,9 +180,9 @@ def test_some_uncorrectable(self, size):
class TestNonSystematic:
@pytest.mark.parametrize("size", CODES)
def test_all_correctable(self, size):
n, k = size[0], size[1]
n, k, c = size[0], size[1], size[2]
N = 100
rs = galois.ReedSolomon(n, k, systematic=False)
rs = galois.ReedSolomon(n, k, c=c, systematic=False)
GF = rs.field
M = GF.Random((N, k))
C = rs.encode(M)
Expand All @@ -209,9 +209,9 @@ def test_all_correctable(self, size):

@pytest.mark.parametrize("size", CODES)
def test_some_uncorrectable(self, size):
n, k = size[0], size[1]
n, k, c = size[0], size[1], size[2]
N = 100
rs = galois.ReedSolomon(n, k, systematic=False)
rs = galois.ReedSolomon(n, k, c=c, systematic=False)
GF = rs.field
M = GF.Random((N, k))
C = rs.encode(M)
Expand Down
26 changes: 13 additions & 13 deletions tests/codes/test_rs_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
import galois

CODES = [
(15, 13), # GF(2^4) with t=1
(15, 11), # GF(2^4) with t=2
(15, 9), # GF(2^4) with t=3
(15, 7), # GF(2^4) with t=4
(15, 5), # GF(2^4) with t=5
(15, 3), # GF(2^4) with t=6
(15, 1), # GF(2^4) with t=7
(16, 14), # GF(17) with t=1
(16, 12), # GF(17) with t=2
(16, 10), # GF(17) with t=3
(26, 24), # GF(3^3) with t=1
(26, 22), # GF(3^3) with t=2
(26, 20), # GF(3^3) with t=3
(15, 13, 1), # GF(2^4) with t=1
(15, 11, 2), # GF(2^4) with t=2
(15, 9, 1), # GF(2^4) with t=3
(15, 7, 2), # GF(2^4) with t=4
(15, 5, 1), # GF(2^4) with t=5
(15, 3, 2), # GF(2^4) with t=6
(15, 1, 1), # GF(2^4) with t=7
(16, 14, 2), # GF(17) with t=1
(16, 12, 1), # GF(17) with t=2
(16, 10, 2), # GF(17) with t=3
(26, 24, 1), # GF(3^3) with t=1
(26, 22, 2), # GF(3^3) with t=2
(26, 20, 3), # GF(3^3) with t=3
]


Expand Down

0 comments on commit 3d90c8a

Please sign in to comment.