Skip to content

Commit

Permalink
Expand tests to cover ufunc_mode="python-calculate"
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Jun 22, 2024
1 parent 5132ed8 commit 4a6419a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tests/fields/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
FIELDS_DIFF_MODES = [
# Binary field
pytest.param("GF(2)-jit-calculate"),
pytest.param("GF(2)-python-calculate"),
# Binary extension fields
pytest.param("GF(2^2)-jit-lookup"),
pytest.param("GF(2^2)-jit-calculate"),
Expand All @@ -52,8 +53,10 @@
# Prime fields
pytest.param("GF(5)-jit-lookup"),
pytest.param("GF(5)-jit-calculate"),
pytest.param("GF(5)-python-calculate"),
pytest.param("GF(7)-jit-lookup"),
pytest.param("GF(7)-jit-calculate"),
pytest.param("GF(7)-python-calculate"),
pytest.param("GF(31)-jit-lookup"),
pytest.param("GF(31)-jit-calculate"),
pytest.param("GF(3191)-jit-lookup"),
Expand All @@ -76,7 +79,7 @@ def construct_field(folder):
ufunc_mode = "auto"

if folder == "GF(2)":
GF = galois.GF2
GF = galois.GF(2, compile=ufunc_mode)

elif folder == "GF(5)":
GF = galois.GF(5, compile=ufunc_mode)
Expand Down
6 changes: 4 additions & 2 deletions tests/fields/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import random

import numpy as np
import pytest

import galois

Expand Down Expand Up @@ -218,11 +219,12 @@ def test_log_different_base(field_log):
assert np.array_equal(beta**z, x)


def test_log_pollard_rho():
@pytest.mark.parametrize("ufunc_mode", ["jit-calculate", "python-calculate"])
def test_log_pollard_rho(ufunc_mode):
"""
The Pollard-rho discrete logarithm algorithm is only applicable for fields when p^m - 1 is prime.
"""
GF = galois.GF(2**19, compile="jit-calculate")
GF = galois.GF(2**5, compile=ufunc_mode)
assert isinstance(GF._log, galois._domains._calculate.log_pollard_rho)
dtype = random.choice(GF.dtypes)
x = GF.Random(10, low=1, dtype=dtype)
Expand Down

0 comments on commit 4a6419a

Please sign in to comment.