GRS doesn't properly check for field of column multipliers

Issue #23 resolved
Johan Rosenkilde created an issue
F = GF(59)
n, k = 40, 12
F3 = GF(3)
try:
    C = GeneralizedReedSolomonCode(F, n, k, F.list()[:n], [F3(2)]+[F.one()]*(n-1))
    assert False , "Shouldn't be accepted"
except ValueError, e:
    print "This should be an error for non-zero column multipliers:\n\t", e

The problem is in grs.py on the line

        if (c in F for c in column_multipliers) == False:
            raise ValueError("All column_multipliers must be elements of the field")

This code is semantically wrong. You should use the function all() to check whether a list/generating expr of bools are all true.

Comments (4)

  1. Johan Rosenkilde reporter
    • changed status to open

    Check your fix before you close the issue! Now your code rejects column multipliers exactly when they are all from the field.

  2. Log in to comment