Skip to content

Commit 8a16247

Browse files
committed
Fix some style issues in docstrings, make pydocstyle check pass
The check to run is: ``` pydocstyle . --ignore=D401,D212,D413,D100 --match='(?!_types.py).*\.py' ``` `_types.py` is excluded because it's a private file, and it's too fiddly and not necessary to add docstrings to the classes in that file.
1 parent 8e3c395 commit 8a16247

File tree

7 files changed

+13
-19
lines changed

7 files changed

+13
-19
lines changed

spec/API_specification/array_api/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Function stubs and API documentation for the array API standard."""
2+
13
from .array_object import *
24
from .constants import *
35
from .creation_functions import *

spec/API_specification/array_api/_types.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This file defines the types for type annotations.
2+
Types for type annotations used in the array API standard.
33
44
The type variables should be replaced with the actual types for a given
55
library, e.g., for NumPy TypeVar('array') would be replaced with ndarray.
@@ -33,6 +33,7 @@
3333

3434
@dataclass
3535
class finfo_object:
36+
"""Dataclass returned by `finfo`."""
3637
bits: int
3738
eps: float
3839
max: float
@@ -42,6 +43,7 @@ class finfo_object:
4243

4344
@dataclass
4445
class iinfo_object:
46+
"""Dataclass returned by `iinfo`."""
4547
bits: int
4648
max: int
4749
min: int

spec/API_specification/array_api/array_object.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
class _array:
1818
def __init__(self: array) -> None:
19-
"""
20-
Initialize the attributes for the array object class.
21-
"""
19+
"""Initialize the attributes for the array object class."""
2220

2321
@property
2422
def dtype(self: array) -> Dtype:

spec/API_specification/array_api/creation_functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def eye(
156156
dtype: Optional[dtype] = None,
157157
device: Optional[device] = None,
158158
) -> array:
159-
"""
159+
r"""
160160
Returns a two-dimensional array with ones on the ``k``\th diagonal and zeros elsewhere.
161161
162162
.. note::

spec/API_specification/array_api/linalg.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ def inv(x: array, /) -> array:
228228

229229

230230
def matmul(x1: array, x2: array, /) -> array:
231-
"""
232-
Alias for :func:`~array_api.matmul`.
233-
"""
231+
"""Alias for :func:`~array_api.matmul`."""
234232

235233

236234
def matrix_norm(
@@ -332,9 +330,7 @@ def matrix_rank(x: array, /, *, rtol: Optional[Union[float, array]] = None) -> a
332330

333331

334332
def matrix_transpose(x: array, /) -> array:
335-
"""
336-
Alias for :func:`~array_api.matrix_transpose`.
337-
"""
333+
"""Alias for :func:`~array_api.matrix_transpose`."""
338334

339335

340336
def outer(x1: array, x2: array, /) -> array:
@@ -603,9 +599,7 @@ def tensordot(
603599
*,
604600
axes: Union[int, Tuple[Sequence[int], Sequence[int]]] = 2,
605601
) -> array:
606-
"""
607-
Alias for :func:`~array_api.tensordot`.
608-
"""
602+
"""Alias for :func:`~array_api.tensordot`."""
609603

610604

611605
def trace(x: array, /, *, offset: int = 0, dtype: Optional[dtype] = None) -> array:
@@ -660,9 +654,7 @@ def trace(x: array, /, *, offset: int = 0, dtype: Optional[dtype] = None) -> arr
660654

661655

662656
def vecdot(x1: array, x2: array, /, *, axis: int = None) -> array:
663-
"""
664-
Alias for :func:`~array_api.vecdot`.
665-
"""
657+
"""Alias for :func:`~array_api.vecdot`."""
666658

667659

668660
def vector_norm(

spec/API_specification/array_api/linear_algebra_functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def tensordot(
105105

106106

107107
def vecdot(x1: array, x2: array, /, *, axis: int = -1) -> array:
108-
"""
108+
r"""
109109
Computes the (vector) dot product of two arrays.
110110
111111
Let :math:`\mathbf{a}` be a vector in ``x1`` and :math:`\mathbf{b}` be a corresponding vector in ``x2``. The dot product is defined as

spec/API_specification/array_api/manipulation_functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def stack(arrays: Union[Tuple[array, ...], List[array]], /, *, axis: int = 0) ->
190190
axis along which the arrays will be joined. Providing an ``axis`` specifies the index of the new axis in the dimensions of the result. For example, if ``axis`` is ``0``, the new axis will be the first dimension and the output array will have shape ``(N, A, B, C)``; if ``axis`` is ``1``, the new axis will be the second dimension and the output array will have shape ``(A, N, B, C)``; and, if ``axis`` is ``-1``, the new axis will be the last dimension and the output array will have shape ``(A, B, C, N)``. A valid ``axis`` must be on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If provided an ``axis`` outside of the required interval, the function must raise an exception. Default: ``0``.
191191
192192
Returns
193-
--------
193+
-------
194194
out: array
195195
an output array having rank ``N+1``, where ``N`` is the rank (number of dimensions) of ``x``. If the input arrays have different data types, normal :ref:`type-promotion` must apply. If the input arrays have the same data type, the output array must have the same data type as the input arrays.
196196

0 commit comments

Comments
 (0)