Skip to content

Commit

Permalink
Update irreducible and primitive poly unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Aug 5, 2021
1 parent b6d8927 commit af18ab0
Show file tree
Hide file tree
Showing 7 changed files with 1,414 additions and 390 deletions.
4 changes: 2 additions & 2 deletions docs/api/polys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Polynomial functions
poly_pow
poly_factors

Special polynomial creation
---------------------------
Special polynomials
-------------------

.. rubric::
.. autosummary::
Expand Down
12 changes: 12 additions & 0 deletions galois/_field/_poly_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ def irreducible_poly(characteristic, degree, method="min"):
galois.is_irreducible(p)
galois.is_irreducible(p * GF(3))
"""
if not isinstance(characteristic, (int, np.integer)):
raise TypeError(f"Argument `characteristic` must be an integer, not {type(characteristic)}.")
if not isinstance(degree, (int, np.integer)):
raise TypeError(f"Argument `degree` must be an integer, not {type(degree)}.")
if not degree >= 1:
raise ValueError(f"Argument `degree` must be at least 1, not {degree}.")
if not method in ["min", "max", "random"]:
raise ValueError(f"Argument `method` must be in ['min', 'max', 'random'], not {method!r}.")
GF = GF_prime(characteristic)
Expand Down Expand Up @@ -423,6 +429,12 @@ def irreducible_polys(characteristic, degree):
galois.irreducible_polys(2, 5)
"""
if not isinstance(characteristic, (int, np.integer)):
raise TypeError(f"Argument `characteristic` must be an integer, not {type(characteristic)}.")
if not isinstance(degree, (int, np.integer)):
raise TypeError(f"Argument `degree` must be an integer, not {type(degree)}.")
if not degree >= 1:
raise ValueError(f"Argument `degree` must be at least 1, not {degree}.")
GF = GF_prime(characteristic)

# Only search monic polynomials of degree m over GF(p)
Expand Down
2 changes: 1 addition & 1 deletion tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def randint(low, high, shape, dtype):
# For dtype=object
array = np.empty(shape, dtype=dtype)
iterator = np.nditer(array, flags=["multi_index", "refs_ok"])
for i in iterator:
for _ in iterator:
array[iterator.multi_index] = random.randint(low, high - 1)
return array
Loading

0 comments on commit af18ab0

Please sign in to comment.