Skip to content

Commit

Permalink
Update with new Ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Jun 9, 2024
1 parent 61cde6a commit d3df018
Show file tree
Hide file tree
Showing 102 changed files with 137 additions and 70 deletions.
1 change: 1 addition & 0 deletions benchmarks/test_fec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A pytest module to benchmark forward-error correction encoding/decoding.
"""

import numpy as np
import pytest

Expand Down
1 change: 1 addition & 0 deletions benchmarks/test_field_arithmetic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A pytest module to benchmark FieldArray arithmetic.
"""

import numpy as np
import pytest

Expand Down
1 change: 1 addition & 0 deletions scripts/create_conway_polys_database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A script to create a database of Conway polynomials using Frank Luebeck's compilation of polynomials.
"""

from __future__ import annotations

import hashlib
Expand Down
1 change: 1 addition & 0 deletions scripts/create_irreducible_polys_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Gadiel Seroussi. Table of Low-Weight Binary Irreducible Polynomials (1998): https://www.hpl.hp.com/techreports/98/HPL-98-135.html
"""

from __future__ import annotations

import hashlib
Expand Down
1 change: 1 addition & 0 deletions scripts/create_prime_factors_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A script to create a database of prime factorizations of p^n +/- 1 using the Cunningham Project's tables.
https://homes.cerias.purdue.edu/~ssw/cun/
"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_fec_test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Install SageMath:
* `sudo apt install sagemath`
"""

import os
import pickle
import shutil
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_field_test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Install SageMath:
* `sudo apt install sagemath`
"""

import json
import os
import pickle
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_int_test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* `sudo apt install sagemath`
"""

import os
import pickle
import random
Expand Down
1 change: 1 addition & 0 deletions src/galois/_codes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
A subpackage containing forward error correction codes.
"""

from ._bch import *
from ._reed_solomon import *
7 changes: 3 additions & 4 deletions src/galois/_codes/_bch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module containing general Bose-Chaudhuri-Hocquenghem (BCH) codes over GF(q).
"""

from __future__ import annotations

from typing import Type, overload
Expand Down Expand Up @@ -481,17 +482,15 @@ def decode(
codeword: ArrayLike,
output: Literal["message", "codeword"] = "message",
errors: Literal[False] = False,
) -> FieldArray:
...
) -> FieldArray: ...

@overload
def decode(
self,
codeword: ArrayLike,
output: Literal["message", "codeword"] = "message",
errors: Literal[True] = True,
) -> tuple[FieldArray, int | np.ndarray]:
...
) -> tuple[FieldArray, int | np.ndarray]: ...

@extend_docstring(
_CyclicCode.decode,
Expand Down
7 changes: 3 additions & 4 deletions src/galois/_codes/_cyclic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module containing common functions for cyclic codes.
"""

from __future__ import annotations

from typing import overload
Expand Down Expand Up @@ -88,17 +89,15 @@ def decode(
codeword: ArrayLike,
output: Literal["message", "codeword"] = "message",
errors: Literal[False] = False,
) -> FieldArray:
...
) -> FieldArray: ...

@overload
def decode(
self,
codeword: ArrayLike,
output: Literal["message", "codeword"] = "message",
errors: Literal[True] = True,
) -> tuple[FieldArray, int | np.ndarray]:
...
) -> tuple[FieldArray, int | np.ndarray]: ...

@extend_docstring(
_LinearCode.decode,
Expand Down
7 changes: 3 additions & 4 deletions src/galois/_codes/_linear.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module containing common functions for linear block codes.
"""

from __future__ import annotations

from typing import Type, overload
Expand Down Expand Up @@ -121,17 +122,15 @@ def decode(
codeword: ArrayLike,
output: Literal["message", "codeword"] = "message",
errors: Literal[False] = False,
) -> FieldArray:
...
) -> FieldArray: ...

@overload
def decode(
self,
codeword: ArrayLike,
output: Literal["message", "codeword"] = "message",
errors: Literal[True] = True,
) -> tuple[FieldArray, int | np.ndarray]:
...
) -> tuple[FieldArray, int | np.ndarray]: ...

def decode(self, codeword, output="message", errors=False):
r"""
Expand Down
7 changes: 3 additions & 4 deletions src/galois/_codes/_reed_solomon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module containing general Reed-Solomon (RS) codes.
"""

from __future__ import annotations

from typing import Type, overload
Expand Down Expand Up @@ -437,17 +438,15 @@ def decode(
codeword: ArrayLike,
output: Literal["message", "codeword"] = "message",
errors: Literal[False] = False,
) -> FieldArray:
...
) -> FieldArray: ...

@overload
def decode(
self,
codeword: ArrayLike,
output: Literal["message", "codeword"] = "message",
errors: Literal[True] = True,
) -> tuple[FieldArray, int | np.ndarray]:
...
) -> tuple[FieldArray, int | np.ndarray]: ...

@extend_docstring(
_CyclicCode.decode,
Expand Down
1 change: 1 addition & 0 deletions src/galois/_databases/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A subpackage containing databases of polynomials and other data.
"""

from ._interface import (
ConwayPolyDatabase,
IrreduciblePolyDatabase,
Expand Down
1 change: 1 addition & 0 deletions src/galois/_databases/_interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module that handles interfacing with the SQLite databases.
"""

from __future__ import annotations

import sqlite3
Expand Down
1 change: 1 addition & 0 deletions src/galois/_domains/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""
A subpackage containing abstract base classes for arrays over Galois fields or rings.
"""

from ._array import *
1 change: 1 addition & 0 deletions src/galois/_domains/_array.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module that defines the abstract base class Array.
"""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions src/galois/_domains/_calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A module containing various ufunc dispatchers with explicit calculation arithmetic added. Various algorithms for
each type of arithmetic are implemented here.
"""

from typing import Type

import numba
Expand Down
1 change: 1 addition & 0 deletions src/galois/_domains/_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A module for for creating Array subclasses. These functions are provided to prevent circular dependencies.
They will be monkey-patched in galois/__init__.py.
"""

from typing import Type

from ._array import Array
Expand Down
1 change: 1 addition & 0 deletions src/galois/_domains/_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A module that contains a NumPy function dispatcher and an Array mixin class that override NumPy functions. The function
dispatcher classes have snake_case naming because they are act like functions.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Callable, Type
Expand Down
1 change: 1 addition & 0 deletions src/galois/_domains/_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A module that contains Array mixin classes that override NumPy linear algebra functions. Additional functions not
included in NumPy are also included.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Type
Expand Down
1 change: 1 addition & 0 deletions src/galois/_domains/_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exponential, logarithm (base primitive element), and Zech logarithm (base primitive element) lookup tables to reduce
the complex finite field arithmetic to a few table lookups and an integer addition/subtraction.
"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/galois/_domains/_meta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module that defines the metaclass for the abstract base class Array.
"""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions src/galois/_domains/_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
arithmetic and lookup table construction. Then in `_calculate.py` the ufunc dispatchers will be subclassed to add
unique explicit calculation algorithms.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Callable, Type
Expand Down
1 change: 1 addition & 0 deletions src/galois/_fields/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A subpackage containing arrays over Galois fields.
"""

from ._array import *
from ._factory import *
from ._gf2 import *
Expand Down
1 change: 1 addition & 0 deletions src/galois/_fields/_array.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module that defines the abstract base class FieldArray.
"""

from __future__ import annotations

from typing import Generator
Expand Down
13 changes: 5 additions & 8 deletions src/galois/_fields/_factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module to implement the Galois field class factory `GF()`.
"""

from __future__ import annotations

import sys
Expand Down Expand Up @@ -29,8 +30,7 @@ def GF(
verify: bool = True,
compile: Literal["auto", "jit-lookup", "jit-calculate", "python-calculate"] | None = None,
repr: Literal["int", "poly", "power"] | None = None,
) -> Type[FieldArray]:
...
) -> Type[FieldArray]: ...


@overload
Expand All @@ -43,8 +43,7 @@ def GF(
verify: bool = True,
compile: Literal["auto", "jit-lookup", "jit-calculate", "python-calculate"] | None = None,
repr: Literal["int", "poly", "power"] | None = None,
) -> Type[FieldArray]:
...
) -> Type[FieldArray]: ...


@export
Expand Down Expand Up @@ -307,8 +306,7 @@ def Field(
verify: bool = True,
compile: Literal["auto", "jit-lookup", "jit-calculate", "python-calculate"] | None = None,
repr: Literal["int", "poly", "power"] | None = None,
) -> Type[FieldArray]:
...
) -> Type[FieldArray]: ...


@overload
Expand All @@ -321,8 +319,7 @@ def Field(
verify: bool = True,
compile: Literal["auto", "jit-lookup", "jit-calculate", "python-calculate"] | None = None,
repr: Literal["int", "poly", "power"] | None = None,
) -> Type[FieldArray]:
...
) -> Type[FieldArray]: ...


@export
Expand Down
1 change: 1 addition & 0 deletions src/galois/_fields/_gf2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module that defines the GF(2) array class.
"""

from __future__ import annotations

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/galois/_fields/_meta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module that defines the metaclass for the abstract base class FieldArray.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Type
Expand Down
1 change: 1 addition & 0 deletions src/galois/_fields/_primitive_element.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module containing functions to generate and test primitive elements of finite fields.
"""

from __future__ import annotations

import random
Expand Down
1 change: 1 addition & 0 deletions src/galois/_fields/_ufunc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module that defines a mixin classes for Galois field arithmetic.
"""

from __future__ import annotations

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/galois/_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A module containing various helper functions for the library.
"""

import builtins
import inspect
import sys
Expand Down
Loading

0 comments on commit d3df018

Please sign in to comment.