summaryrefslogtreecommitdiff
path: root/numpy/array_api/_linear_algebra_functions.py
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2021-08-06 18:22:00 -0600
committerAaron Meurer <asmeurer@gmail.com>2021-08-06 18:23:04 -0600
commit8f7d00ed447174d9398af3365709222b529c1cad (patch)
tree9de0a3a757a8c8a7393787ee1449e087c284d6e1 /numpy/array_api/_linear_algebra_functions.py
parent21923a5fa71bfadf7dee0bb5b110cc2a5719eaac (diff)
downloadnumpy-8f7d00ed447174d9398af3365709222b529c1cad.tar.gz
Run (selective) black on the array_api submodule
I've omitted a few changes from black that messed up the readability of some complicated if statements that were organized logically line-by-line, and some changes that use unnecessary operator spacing.
Diffstat (limited to 'numpy/array_api/_linear_algebra_functions.py')
-rw-r--r--numpy/array_api/_linear_algebra_functions.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/numpy/array_api/_linear_algebra_functions.py b/numpy/array_api/_linear_algebra_functions.py
index f13f9c541..089081725 100644
--- a/numpy/array_api/_linear_algebra_functions.py
+++ b/numpy/array_api/_linear_algebra_functions.py
@@ -17,6 +17,7 @@ import numpy as np
# """
# return np.einsum()
+
def matmul(x1: Array, x2: Array, /) -> Array:
"""
Array API compatible wrapper for :py:func:`np.matmul <numpy.matmul>`.
@@ -26,23 +27,31 @@ def matmul(x1: Array, x2: Array, /) -> Array:
# Note: the restriction to numeric dtypes only is different from
# np.matmul.
if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
- raise TypeError('Only numeric dtypes are allowed in matmul')
+ raise TypeError("Only numeric dtypes are allowed in matmul")
# Call result type here just to raise on disallowed type combinations
_result_type(x1.dtype, x2.dtype)
return Array._new(np.matmul(x1._array, x2._array))
+
# Note: axes must be a tuple, unlike np.tensordot where it can be an array or array-like.
-def tensordot(x1: Array, x2: Array, /, *, axes: Union[int, Tuple[Sequence[int], Sequence[int]]] = 2) -> Array:
+def tensordot(
+ x1: Array,
+ x2: Array,
+ /,
+ *,
+ axes: Union[int, Tuple[Sequence[int], Sequence[int]]] = 2,
+) -> Array:
# Note: the restriction to numeric dtypes only is different from
# np.tensordot.
if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
- raise TypeError('Only numeric dtypes are allowed in tensordot')
+ raise TypeError("Only numeric dtypes are allowed in tensordot")
# Call result type here just to raise on disallowed type combinations
_result_type(x1.dtype, x2.dtype)
return Array._new(np.tensordot(x1._array, x2._array, axes=axes))
+
def transpose(x: Array, /, *, axes: Optional[Tuple[int, ...]] = None) -> Array:
"""
Array API compatible wrapper for :py:func:`np.transpose <numpy.transpose>`.
@@ -51,6 +60,7 @@ def transpose(x: Array, /, *, axes: Optional[Tuple[int, ...]] = None) -> Array:
"""
return Array._new(np.transpose(x._array, axes=axes))
+
# Note: vecdot is not in NumPy
def vecdot(x1: Array, x2: Array, /, *, axis: Optional[int] = None) -> Array:
if axis is None: