Skip to content

Commit 0cbe5a3

Browse files
committed
Add NDArray to IterableLike
Fixes #603
1 parent c1e4be0 commit 0cbe5a3

1 file changed

Lines changed: 39 additions & 6 deletions

File tree

src/galois/typing.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
from ._domains._array import Array
1515
from ._polys._poly import Poly
1616

17-
ElementLike = Union[int, str, "Array"]
17+
ElementLike = Union[
18+
int,
19+
str,
20+
"Array",
21+
]
1822
"""
1923
A :obj:`~typing.Union` representing objects that can be coerced into a Galois field element.
2024
@@ -60,7 +64,11 @@
6064
"""
6165

6266

63-
IterableLike = Union[Sequence[ElementLike], Sequence["IterableLike"]]
67+
IterableLike = Union[
68+
Sequence[ElementLike],
69+
Sequence["IterableLike"],
70+
np.ndarray,
71+
]
6472
"""
6573
A :obj:`~typing.Union` representing iterable objects that can be coerced into a Galois field array.
6674
@@ -86,11 +94,23 @@
8694
# Mix and match integers and strings
8795
GF([["x^2 + 2x + 2", 4], ["x^4 + 2x^3 + x^2 + x + 1", 205]])
8896
97+
- :obj:`~numpy.ndarray`: A NumPy array of integers, representing finite field elements in their :ref:`integer
98+
representation <int-repr>`.
99+
100+
.. ipython-with-reprs:: int,poly,power
101+
102+
x = np.array([[17, 4], [148, 205]]); x
103+
GF(x)
104+
89105
.. rubric:: Alias
90106
"""
91107

92108

93-
ArrayLike = Union[IterableLike, np.ndarray, "Array"]
109+
ArrayLike = Union[
110+
IterableLike,
111+
np.ndarray,
112+
"Array",
113+
]
94114
"""
95115
A :obj:`~typing.Union` representing objects that can be coerced into a Galois field array.
96116
@@ -121,7 +141,10 @@
121141
"""
122142

123143

124-
ShapeLike = Union[int, Sequence[int]]
144+
ShapeLike = Union[
145+
int,
146+
Sequence[int],
147+
]
125148
"""
126149
A :obj:`~typing.Union` representing objects that can be coerced into a NumPy :obj:`~numpy.ndarray.shape` tuple.
127150
@@ -153,7 +176,12 @@
153176
"""
154177

155178

156-
DTypeLike = Union[np.integer, int, str, object]
179+
DTypeLike = Union[
180+
np.integer,
181+
int,
182+
str,
183+
object,
184+
]
157185
"""
158186
A :obj:`~typing.Union` representing objects that can be coerced into a NumPy data type.
159187
@@ -193,7 +221,12 @@
193221
"""
194222

195223

196-
PolyLike = Union[int, str, ArrayLike, "Poly"]
224+
PolyLike = Union[
225+
int,
226+
str,
227+
ArrayLike,
228+
"Poly",
229+
]
197230
"""
198231
A :obj:`~typing.Union` representing objects that can be coerced into a polynomial.
199232

0 commit comments

Comments
 (0)