Skip to content

Commit fcd0dba

Browse files
committed
DOC: italicize should/must in stubs docstrings
1 parent 382a4dd commit fcd0dba

16 files changed

+611
-611
lines changed

src/array_api_stubs/_draft/_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Types for type annotations used in the array API standard.
33
4-
The type variables should be replaced with the actual types for a given
4+
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.
66
"""
77
from __future__ import annotations

src/array_api_stubs/_draft/array_object.py

+91-91
Large diffs are not rendered by default.

src/array_api_stubs/_draft/creation_functions.py

+45-45
Large diffs are not rendered by default.

src/array_api_stubs/_draft/data_type_functions.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ def astype(
2222
Casting floating-point ``NaN`` and ``infinity`` values to integral data types is not specified and is implementation-dependent.
2323
2424
.. note::
25-
Casting a complex floating-point array to a real-valued data type should not be permitted.
25+
Casting a complex floating-point array to a real-valued data type *should not* be permitted.
2626
27-
Historically, when casting a complex floating-point array to a real-valued data type, libraries such as NumPy have discarded imaginary components such that, for a complex floating-point array ``x``, ``astype(x)`` equals ``astype(real(x))``). This behavior is considered problematic as the choice to discard the imaginary component is arbitrary and introduces more than one way to achieve the same outcome (i.e., for a complex floating-point array ``x``, ``astype(x)`` and ``astype(real(x))`` versus only ``astype(imag(x))``). Instead, in order to avoid ambiguity and to promote clarity, this specification requires that array API consumers explicitly express which component should be cast to a specified real-valued data type.
27+
Historically, when casting a complex floating-point array to a real-valued data type, libraries such as NumPy have discarded imaginary components such that, for a complex floating-point array ``x``, ``astype(x)`` equals ``astype(real(x))``). This behavior is considered problematic as the choice to discard the imaginary component is arbitrary and introduces more than one way to achieve the same outcome (i.e., for a complex floating-point array ``x``, ``astype(x)`` and ``astype(real(x))`` versus only ``astype(imag(x))``). Instead, in order to avoid ambiguity and to promote clarity, this specification requires that array API consumers explicitly express which component *should* be cast to a specified real-valued data type.
2828
2929
.. note::
30-
When casting a boolean input array to a real-valued data type, a value of ``True`` must cast to a real-valued number equal to ``1``, and a value of ``False`` must cast to a real-valued number equal to ``0``.
30+
When casting a boolean input array to a real-valued data type, a value of ``True`` *must* cast to a real-valued number equal to ``1``, and a value of ``False`` *must* cast to a real-valued number equal to ``0``.
3131
32-
When casting a boolean input array to a complex floating-point data type, a value of ``True`` must cast to a complex number equal to ``1 + 0j``, and a value of ``False`` must cast to a complex number equal to ``0 + 0j``.
32+
When casting a boolean input array to a complex floating-point data type, a value of ``True`` *must* cast to a complex number equal to ``1 + 0j``, and a value of ``False`` *must* cast to a complex number equal to ``0 + 0j``.
3333
3434
.. note::
35-
When casting a real-valued input array to ``bool``, a value of ``0`` must cast to ``False``, and a non-zero value must cast to ``True``.
35+
When casting a real-valued input array to ``bool``, a value of ``0`` *must* cast to ``False``, and a non-zero value *must* cast to ``True``.
3636
37-
When casting a complex floating-point array to ``bool``, a value of ``0 + 0j`` must cast to ``False``, and all other values must cast to ``True``.
37+
When casting a complex floating-point array to ``bool``, a value of ``0 + 0j`` *must* cast to ``False``, and all other values *must* cast to ``True``.
3838
3939
Parameters
4040
----------
@@ -43,14 +43,14 @@ def astype(
4343
dtype: dtype
4444
desired data type.
4545
copy: bool
46-
specifies whether to copy an array when the specified ``dtype`` matches the data type of the input array ``x``. If ``True``, a newly allocated array must always be returned. If ``False`` and the specified ``dtype`` matches the data type of the input array, the input array must be returned; otherwise, a newly allocated array must be returned. Default: ``True``.
46+
specifies whether to copy an array when the specified ``dtype`` matches the data type of the input array ``x``. If ``True``, a newly allocated array *must* always be returned. If ``False`` and the specified ``dtype`` matches the data type of the input array, the input array *must* be returned; otherwise, a newly allocated array *must* be returned. Default: ``True``.
4747
device: Optional[device]
48-
device on which to place the returned array. If ``device`` is ``None``, the output array device must be inferred from ``x``. Default: ``None``.
48+
device on which to place the returned array. If ``device`` is ``None``, the output array device *must* be inferred from ``x``. Default: ``None``.
4949
5050
Returns
5151
-------
5252
out: array
53-
an array having the specified data type. The returned array must have the same shape as ``x``.
53+
an array having the specified data type. The returned array *must* have the same shape as ``x``.
5454
5555
Notes
5656
-----
@@ -91,7 +91,7 @@ def finfo(type: Union[dtype, array], /) -> finfo_object:
9191
the kind of floating-point data-type about which to get information. If complex, the information is about its component data type.
9292
9393
.. note::
94-
Complex floating-point data types are specified to always use the same precision for both its real and imaginary components, so the information should be true for either component.
94+
Complex floating-point data types are specified to always use the same precision for both its real and imaginary components, so the information *should* be true for either component.
9595
9696
Returns
9797
-------
@@ -179,8 +179,8 @@ def isdtype(
179179
kind: Union[str, dtype, Tuple[Union[str, dtype], ...]]
180180
data type kind.
181181
182-
- If ``kind`` is a dtype, the function must return a boolean indicating whether the input ``dtype`` is equal to the dtype specified by ``kind``.
183-
- If ``kind`` is a string, the function must return a boolean indicating whether the input ``dtype`` is of a specified data type kind. The following dtype kinds must be supported:
182+
- If ``kind`` is a dtype, the function *must* return a boolean indicating whether the input ``dtype`` is equal to the dtype specified by ``kind``.
183+
- If ``kind`` is a string, the function *must* return a boolean indicating whether the input ``dtype`` is of a specified data type kind. The following dtype kinds *must* be supported:
184184
185185
- ``'bool'``: boolean data types (e.g., ``bool``).
186186
- ``'signed integer'``: signed integer data types (e.g., ``int8``, ``int16``, ``int32``, ``int64``).
@@ -190,12 +190,12 @@ def isdtype(
190190
- ``'complex floating'``: complex floating-point data types (e.g., ``complex64``, ``complex128``).
191191
- ``'numeric'``: numeric data types. Shorthand for ``('integral', 'real floating', 'complex floating')``.
192192
193-
- If ``kind`` is a tuple, the tuple specifies a union of dtypes and/or kinds, and the function must return a boolean indicating whether the input ``dtype`` is either equal to a specified dtype or belongs to at least one specified data type kind.
193+
- If ``kind`` is a tuple, the tuple specifies a union of dtypes and/or kinds, and the function *must* return a boolean indicating whether the input ``dtype`` is either equal to a specified dtype or belongs to at least one specified data type kind.
194194
195195
.. note::
196196
A conforming implementation of the array API standard is **not** limited to only including the dtypes described in this specification in the required data type kinds. For example, implementations supporting ``float16`` and ``bfloat16`` can include ``float16`` and ``bfloat16`` in the ``real floating`` data type kind. Similarly, implementations supporting ``int128`` can include ``int128`` in the ``signed integer`` data type kind.
197197
198-
In short, conforming implementations may extend data type kinds; however, data type kinds must remain consistent (e.g., only integer dtypes may belong to integer data type kinds and only floating-point dtypes may belong to floating-point data type kinds), and extensions must be clearly documented as such in library documentation.
198+
In short, conforming implementations may extend data type kinds; however, data type kinds *must* remain consistent (e.g., only integer dtypes may belong to integer data type kinds and only floating-point dtypes may belong to floating-point data type kinds), and extensions *must* be clearly documented as such in library documentation.
199199
200200
Returns
201201
-------

0 commit comments

Comments
 (0)