Skip to content

PR: Rename signatures module to array_api #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions spec/API_specification/array_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from .array_object import *
from .constants import *
from .creation_functions import *
from .data_type_functions import *
from .data_types import *
from .elementwise_functions import *
from .linear_algebra_functions import *
from .manipulation_functions import *
from .searching_functions import *
from .set_functions import *
from .sorting_functions import *
from .statistical_functions import *
from .utility_functions import *
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __abs__(self: array, /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.abs`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.abs`.
"""

def __add__(self: array, other: Union[int, float, array], /) -> array:
Expand Down Expand Up @@ -181,7 +181,7 @@ def __add__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.add`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.add`.
"""

def __and__(self: array, other: Union[int, bool, array], /) -> array:
Expand All @@ -202,7 +202,7 @@ def __and__(self: array, other: Union[int, bool, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_and`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.bitwise_and`.
"""

def __array_namespace__(self: array, /, *, api_version: Optional[str] = None) -> Any:
Expand Down Expand Up @@ -239,7 +239,7 @@ def __bool__(self: array, /) -> bool:

def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> PyCapsule:
"""
Exports the array for consumption by :func:`~signatures.creation_functions.from_dlpack` as a DLPack capsule.
Exports the array for consumption by :func:`~array_api.creation_functions.from_dlpack` as a DLPack capsule.

Parameters
----------
Expand Down Expand Up @@ -294,7 +294,7 @@ def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> P

def __dlpack_device__(self: array, /) -> Tuple[Enum, int]:
"""
Returns device type and device ID in DLPack format. Meant for use within :func:`~signatures.creation_functions.from_dlpack`.
Returns device type and device ID in DLPack format. Meant for use within :func:`~array_api.creation_functions.from_dlpack`.

Parameters
----------
Expand Down Expand Up @@ -336,7 +336,7 @@ def __eq__(self: array, other: Union[int, float, bool, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.equal`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.equal`.
"""

def __float__(self: array, /) -> float:
Expand Down Expand Up @@ -411,7 +411,7 @@ def __floordiv__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.floor_divide`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.floor_divide`.
"""

def __ge__(self: array, other: Union[int, float, array], /) -> array:
Expand All @@ -432,7 +432,7 @@ def __ge__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.greater_equal`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.greater_equal`.
"""

def __getitem__(self: array, key: Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], array], /) -> array:
Expand Down Expand Up @@ -470,7 +470,7 @@ def __gt__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.greater`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.greater`.
"""

def __index__(self: array, /) -> int:
Expand Down Expand Up @@ -522,7 +522,7 @@ def __invert__(self: array, /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_invert`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.bitwise_invert`.
"""

def __le__(self: array, other: Union[int, float, array], /) -> array:
Expand All @@ -543,7 +543,7 @@ def __le__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.less_equal`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.less_equal`.
"""

def __lshift__(self: array, other: Union[int, array], /) -> array:
Expand All @@ -564,7 +564,7 @@ def __lshift__(self: array, other: Union[int, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_left_shift`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.bitwise_left_shift`.
"""

def __lt__(self: array, other: Union[int, float, array], /) -> array:
Expand All @@ -585,7 +585,7 @@ def __lt__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.less`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.less`.
"""

def __matmul__(self: array, other: array, /) -> array:
Expand Down Expand Up @@ -616,7 +616,7 @@ def __matmul__(self: array, other: array, /) -> array:


.. note::
Results must equal the results returned by the equivalent function :func:`~signatures.linear_algebra_functions.matmul`.
Results must equal the results returned by the equivalent function :func:`~array_api.linear_algebra_functions.matmul`.

**Raises**

Expand Down Expand Up @@ -676,7 +676,7 @@ def __mod__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.remainder`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.remainder`.
"""

def __mul__(self: array, other: Union[int, float, array], /) -> array:
Expand Down Expand Up @@ -715,7 +715,7 @@ def __mul__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.multiply`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.multiply`.
"""

def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:
Expand All @@ -736,7 +736,7 @@ def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.not_equal`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.not_equal`.
"""

def __neg__(self: array, /) -> array:
Expand All @@ -758,7 +758,7 @@ def __neg__(self: array, /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.negative`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.negative`.
"""

def __or__(self: array, other: Union[int, bool, array], /) -> array:
Expand All @@ -779,7 +779,7 @@ def __or__(self: array, other: Union[int, bool, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_or`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.bitwise_or`.
"""

def __pos__(self: array, /) -> array:
Expand All @@ -798,7 +798,7 @@ def __pos__(self: array, /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.positive`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.positive`.
"""

def __pow__(self: array, other: Union[int, float, array], /) -> array:
Expand Down Expand Up @@ -853,7 +853,7 @@ def __pow__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.pow`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.pow`.
"""

def __rshift__(self: array, other: Union[int, array], /) -> array:
Expand All @@ -874,7 +874,7 @@ def __rshift__(self: array, other: Union[int, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_right_shift`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.bitwise_right_shift`.
"""

def __setitem__(self: array, key: Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], array], value: Union[int, float, bool, array], /) -> None:
Expand Down Expand Up @@ -918,7 +918,7 @@ def __sub__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.subtract`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.subtract`.
"""

def __truediv__(self: array, other: Union[int, float, array], /) -> array:
Expand Down Expand Up @@ -971,7 +971,7 @@ def __truediv__(self: array, other: Union[int, float, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.divide`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.divide`.
"""

def __xor__(self: array, other: Union[int, bool, array], /) -> array:
Expand All @@ -992,7 +992,7 @@ def __xor__(self: array, other: Union[int, bool, array], /) -> array:


.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_xor`.
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.elementwise_functions.bitwise_xor`.
"""

def to_device(self: array, device: Device, /, *, stream: Optional[Union[int, Any]] = None) -> array:
Expand All @@ -1019,3 +1019,5 @@ def to_device(self: array, device: Device, /, *, stream: Optional[Union[int, Any
"""

array = _array

__all__ = ['array']
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def asarray(obj: Union[array, bool, int, float, NestedSequence, SupportsBufferPr
.. admonition:: Note
:class: note

If ``dtype`` is not ``None``, then array conversions should obey :ref:`type-promotion` rules. Conversions not specified according to :ref:`type-promotion` rules may or may not be permitted by a conforming array library. To perform an explicit cast, use :func:`signatures.data_type_functions.astype`.
If ``dtype`` is not ``None``, then array conversions should obey :ref:`type-promotion` rules. Conversions not specified according to :ref:`type-promotion` rules may or may not be permitted by a conforming array library. To perform an explicit cast, use :func:`array_api.data_type_functions.astype`.

.. note::
If an input value exceeds the precision of the resolved output array data type, behavior is left unspecified and, thus, implementation-defined.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def inv(x: array, /) -> array:

def matmul(x1: array, x2: array, /) -> array:
"""
Alias for :func:`~signatures.linear_algebra_functions.matmul`.
Alias for :func:`~array_api.linear_algebra_functions.matmul`.
"""

def matrix_norm(x: array, /, *, keepdims: bool = False, ord: Optional[Union[int, float, Literal[inf, -inf, 'fro', 'nuc']]] = 'fro') -> array:
Expand Down Expand Up @@ -249,7 +249,7 @@ def matrix_rank(x: array, /, *, rtol: Optional[Union[float, array]] = None) -> a

def matrix_transpose(x: array, /) -> array:
"""
Alias for :func:`~signatures.linear_algebra_functions.matrix_transpose`.
Alias for :func:`~array_api.linear_algebra_functions.matrix_transpose`.
"""

def outer(x1: array, x2: array, /) -> array:
Expand Down Expand Up @@ -406,7 +406,7 @@ def svdvals(x: array, /) -> array:

def tensordot(x1: array, x2: array, /, *, axes: Union[int, Tuple[Sequence[int], Sequence[int]]] = 2) -> array:
"""
Alias for :func:`~signatures.linear_algebra_functions.tensordot`.
Alias for :func:`~array_api.linear_algebra_functions.tensordot`.
"""

def trace(x: array, /, *, offset: int = 0) -> array:
Expand Down Expand Up @@ -440,7 +440,7 @@ def trace(x: array, /, *, offset: int = 0) -> array:

def vecdot(x1: array, x2: array, /, *, axis: int = None) -> array:
"""
Alias for :func:`~signatures.linear_algebra_functions.vecdot`.
Alias for :func:`~array_api.linear_algebra_functions.vecdot`.
"""

def vector_norm(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False, ord: Union[int, float, Literal[inf, -inf]] = 2) -> array:
Expand Down
2 changes: 1 addition & 1 deletion spec/API_specification/array_object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Bitwise Operators

-------------------------------------------------

.. currentmodule:: signatures.array_object
.. currentmodule:: array_api.array_object

Attributes
----------
Expand Down
2 changes: 1 addition & 1 deletion spec/API_specification/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A conforming implementation of the array API standard must provide and support t
Objects in API
--------------

.. currentmodule:: signatures.constants
.. currentmodule:: array_api.constants

..
NOTE: please keep the functions in alphabetical order
Expand Down
2 changes: 1 addition & 1 deletion spec/API_specification/creation_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A conforming implementation of the array API standard must provide and support t
Objects in API
--------------

.. currentmodule:: signatures.creation_functions
.. currentmodule:: array_api.creation_functions

..
NOTE: please keep the functions in alphabetical order
Expand Down
2 changes: 1 addition & 1 deletion spec/API_specification/data_type_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A conforming implementation of the array API standard must provide and support t
Objects in API
--------------

.. currentmodule:: signatures.data_type_functions
.. currentmodule:: array_api.data_type_functions

..
NOTE: please keep the functions in alphabetical order
Expand Down
2 changes: 1 addition & 1 deletion spec/API_specification/data_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Methods
..
NOTE: please keep the functions in alphabetical order

.. currentmodule:: signatures.data_types
.. currentmodule:: array_api.data_types

.. autosummary::
:toctree: generated
Expand Down
2 changes: 1 addition & 1 deletion spec/API_specification/elementwise_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A conforming implementation of the array API standard must provide and support t
Objects in API
--------------

.. currentmodule:: signatures.elementwise_functions
.. currentmodule:: array_api.elementwise_functions

..
NOTE: please keep the functions in alphabetical order
Expand Down
4 changes: 2 additions & 2 deletions spec/API_specification/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Multi-dimensional arrays must extend the concept of single-axis indexing to mult
- Each ``None`` in the selection tuple must expand the dimensions of the resulting selection by one dimension of size ``1``. The position of the added dimension must be the same as the position of ``None`` in the selection tuple.

.. note::
Expanding dimensions can be equivalently achieved via repeated invocation of :func:`~signatures.manipulation_functions.expand_dims`.
Expanding dimensions can be equivalently achieved via repeated invocation of :func:`~array_api.manipulation_functions.expand_dims`.

- Except in the case of providing a single ellipsis (e.g., ``A[2:10, ...]`` or ``A[1:, ..., 2:5]``), the number of provided single-axis indexing expressions (excluding ``None``) should equal ``N``. For example, if ``A`` has rank ``2``, a single-axis indexing expression should be explicitly provided for both axes (e.g., ``A[2:10, :]``). An ``IndexError`` exception should be raised if the number of provided single-axis indexing expressions (excluding ``None``) is less than ``N``.

Expand All @@ -181,7 +181,7 @@ Boolean Array Indexing
An array must support indexing where the **sole index** is an ``M``-dimensional boolean array ``B`` with shape ``S1 = (s1, ..., sM)`` according to the following rules. Let ``A`` be an ``N``-dimensional array with shape ``S2 = (s1, ..., sM, ..., sN)``.

.. note::
The prohibition against combining boolean array indices with other single-axis indexing expressions includes the use of ``None``. To expand dimensions of the returned array, use repeated invocation of :func:`~signatures.manipulation_functions.expand_dims`.
The prohibition against combining boolean array indices with other single-axis indexing expressions includes the use of ``None``. To expand dimensions of the returned array, use repeated invocation of :func:`~array_api.manipulation_functions.expand_dims`.

- If ``N >= M``, then ``A[B]`` must replace the first ``M`` dimensions of ``A`` with a single dimension having a size equal to the number of ``True`` elements in ``B``. The values in the resulting array must be in row-major (C-style order); this is equivalent to ``A[nonzero(B)]``.

Expand Down
2 changes: 1 addition & 1 deletion spec/API_specification/linear_algebra_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A conforming implementation of the array API standard must provide and support t
* Unless stated otherwise, functions must adhere to the type promotion rules defined in :ref:`type-promotion`.
* Unless stated otherwise, floating-point operations must adhere to IEEE 754-2019.

.. currentmodule:: signatures.linear_algebra_functions
.. currentmodule:: array_api.linear_algebra_functions

Objects in API
--------------
Expand Down
2 changes: 1 addition & 1 deletion spec/API_specification/manipulation_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A conforming implementation of the array API standard must provide and support t
Objects in API
--------------

.. currentmodule:: signatures.manipulation_functions
.. currentmodule:: array_api.manipulation_functions

..
NOTE: please keep the functions in alphabetical order
Expand Down
Loading