Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NumPy 1.23 #414

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Import the `galois` package in Python.
In [1]: import galois

In [2]: galois.__version__
Out[2]: '0.1.0'
Out[2]: '0.1.1'
```

### Create a [`FieldArray`](https://mhostetter.github.io/galois/latest/api/galois.FieldArray/) subclass
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ If this library was useful to you in your research, please cite us. Following th
:hidden:

release-notes/versioning.rst
release-notes/v0.1.1.md
release-notes/v0.1.0.md
release-notes/v0.0.33.md
release-notes/v0.0.32.md
Expand Down
19 changes: 19 additions & 0 deletions docs/release-notes/v0.1.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# v0.1.1

*Released September 2, 2022*

## Changes

- Added support for NumPy 1.23. ([#414](https://github.com/mhostetter/galois/pull/414))
- Added `seed` keyword argument to `random_prime()`. ([#409](https://github.com/mhostetter/galois/pull/409))
```python
>>> galois.random_prime(100, seed=1)
2218840874040723579228056294021
>>> galois.random_prime(100, seed=1)
2218840874040723579228056294021
```
- Deployed documentation to [https://mhostetter.github.io/galois/latest/](https://mhostetter.github.io/galois/latest/) with GitHub Pages. ([#408](https://github.com/mhostetter/galois/pull/408))

## Contributors

- Matt Hostetter ([@mhostetter](https://github.com/mhostetter))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ classifiers = [
]
requires-python = ">=3.7"
dependencies = [
"numpy >= 1.18.4, < 1.23", # v1.18.4 is needed for the new random
"numpy >= 1.18.4, < 1.24", # v1.18.4 is needed for the new random
"numba >= 0.53, < 0.57", # v0.53 needed for function signautres of CPUDispatchers
"typing_extensions", # Needed for use of Literal in type hints for Python 3.7
]
Expand Down
50 changes: 26 additions & 24 deletions src/galois/_domains/_calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def vector_to_int(a_vec: np.ndarray, characteristic: int, degree: int) -> int:


@numba.jit(["int64[:](int64, int64)"], nopython=True, cache=True)
def egcd(a: int, b: int) -> np.ndarray:
def egcd(a: int, b: int) -> np.ndarray: # pragma: no cover
"""
Computes the Extended Euclidean Algorithm. Returns (d, s, t).

Expand Down Expand Up @@ -79,7 +79,7 @@ def egcd(a: int, b: int) -> np.ndarray:
EGCD = egcd

@numba.jit(["int64(int64[:], int64[:])"], nopython=True, cache=True)
def crt(remainders: np.ndarray, moduli: np.ndarray) -> int:
def crt(remainders: np.ndarray, moduli: np.ndarray) -> int: # pragma: no cover
"""
Computes the simultaneous solution to the system of congruences xi == ai (mod mi).
"""
Expand Down Expand Up @@ -405,29 +405,31 @@ def calculate(a: int) -> int:
return t2


class reciprocal_fermat(_lookup.reciprocal_ufunc):
"""
A ufunc dispatcher that provides the multiplicative inverse using Fermat's Little Theorem.
# NOTE: Commented out because it's not currently being used. This prevents it from being
# flagged as "not covered".
# class reciprocal_fermat(_lookup.reciprocal_ufunc):
# """
# A ufunc dispatcher that provides the multiplicative inverse using Fermat's Little Theorem.

Algorithm:
a in GF(p^m)
a^(p^m - 1) = 1
# Algorithm:
# a in GF(p^m)
# a^(p^m - 1) = 1

a * a^-1 = 1
a * a^-1 = a^(p^m - 1)
a^-1 = a^(p^m - 2)
"""
def set_calculate_globals(self):
global ORDER, POSITIVE_POWER
ORDER = self.field.order
POSITIVE_POWER = self.field._positive_power.ufunc
# a * a^-1 = 1
# a * a^-1 = a^(p^m - 1)
# a^-1 = a^(p^m - 2)
# """
# def set_calculate_globals(self):
# global ORDER, POSITIVE_POWER
# ORDER = self.field.order
# POSITIVE_POWER = self.field._positive_power.ufunc

@staticmethod
def calculate(a: int) -> int:
if a == 0:
raise ZeroDivisionError("Cannot compute the multiplicative inverse of 0 in a Galois field.")
# @staticmethod
# def calculate(a: int) -> int:
# if a == 0:
# raise ZeroDivisionError("Cannot compute the multiplicative inverse of 0 in a Galois field.")

return POSITIVE_POWER(a, ORDER - 2)
# return POSITIVE_POWER(a, ORDER - 2)


class reciprocal_itoh_tsujii(_lookup.reciprocal_ufunc):
Expand Down Expand Up @@ -584,7 +586,7 @@ def set_calculate_globals(self):
MULTIPLY = self.field._multiply.ufunc

@staticmethod
def calculate(beta: int, alpha: int) -> int:
def calculate(beta: int, alpha: int) -> int: # pragma: no cover
"""
beta is an element of GF(p^m)
alpha is a primitive element of GF(p^m)
Expand Down Expand Up @@ -615,7 +617,7 @@ def set_calculate_globals(self):
set_helper_globals(self.field)

@staticmethod
def calculate(beta: int, alpha: int) -> int:
def calculate(beta: int, alpha: int) -> int: # pragma: no cover
"""
beta is an element of GF(p^m)
alpha is a primitive element of GF(p^m)
Expand Down Expand Up @@ -701,7 +703,7 @@ def set_calculate_globals(self):
MULTIPLICITIES = np.array(MULTIPLICITIES, dtype=DTYPE)

@staticmethod
def calculate(beta: int, alpha: int) -> int:
def calculate(beta: int, alpha: int) -> int: # pragma: no cover
"""
beta is an element of GF(p^m)
alpha is a primitive element of GF(p^m)
Expand Down