Skip to content

Commit

Permalink
Fix ValueError messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Nov 17, 2022
1 parent 475212d commit 07783e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/galois/_codes/_bch.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def __init__(
verify_isinstance(c, int)

if d is not None and not d >= 1:
raise ValueError(f"Argument `d` must be at least 1, not {d}.")
raise ValueError(f"Argument 'd' must be at least 1, not {d}.")
if not c >= 0:
raise ValueError(f"Argument `c` must be at least 0, not {c}.")
raise ValueError(f"Argument 'c' must be at least 0, not {c}.")

if field is None:
field = GF2
Expand Down Expand Up @@ -208,7 +208,7 @@ def __init__(
# We know `d` wasn't provided, otherwise the previous `if` would have executed
d = roots.size + 1
else:
raise ValueError("Argument `k` or `d` must be provided to define the code size.")
raise ValueError("Argument 'k' or 'd' must be provided to define the code size.")

# Set BCH specific attributes
self._extension_field = extension_field
Expand Down
8 changes: 4 additions & 4 deletions src/galois/_codes/_reed_solomon.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ def __init__(
verify_isinstance(systematic, bool)

if d is not None and not d >= 1:
raise ValueError(f"Argument `d` must be at least 1, not {d}.")
raise ValueError(f"Argument 'd' must be at least 1, not {d}.")
if not c >= 0:
raise ValueError(f"Argument `c` must be at least 0, not {c}.")
raise ValueError(f"Argument 'c' must be at least 0, not {c}.")

if field is None:
q = 2
Expand All @@ -170,13 +170,13 @@ def __init__(
# Singleton bound, so the relationship between n, k, and d is precise.
if d is not None and k is not None:
if not d == n - k + 1:
raise ValueError("Arguments `k` and `d` were provided but are inconsistent. For Reed-Solomon codes, d = n - k + 1.")
raise ValueError("Arguments 'k' and 'd' were provided but are inconsistent. For Reed-Solomon codes, d = n - k + 1.")
elif d is not None:
k = n - (d - 1)
elif k is not None:
d = (n - k) + 1
else:
raise ValueError("Argument `k` or `d` must be provided to define the code size.")
raise ValueError("Argument 'k' or 'd' must be provided to define the code size.")

roots = alpha ** (c + np.arange(0, d - 1))
generator_poly = Poly.Roots(roots)
Expand Down

0 comments on commit 07783e2

Please sign in to comment.