Skip to content

Commit fc77b0a

Browse files
steff456leofangkgryte
authored
PR: Rename signatures module to array_api (#430)
* Rename signatures module to array_api * Remove unused code * flatten the namespace in both .rst and .py * Export string name * Rename import and fix list of exports * Remove import * Update import Co-authored-by: Leo Fang <leof@nvidia.com> Co-authored-by: Athan Reines <kgryte@gmail.com>
1 parent 48c09fc commit fc77b0a

34 files changed

+66
-49
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from .array_object import *
2+
from .constants import *
3+
from .creation_functions import *
4+
from .data_type_functions import *
5+
import array_api.data_types as dtype
6+
from .elementwise_functions import *
7+
from .linear_algebra_functions import *
8+
from .manipulation_functions import *
9+
from .searching_functions import *
10+
from .set_functions import *
11+
from .sorting_functions import *
12+
from .statistical_functions import *
13+
from .utility_functions import *
14+
from . import linalg

spec/API_specification/signatures/array_object.py renamed to spec/API_specification/array_api/array_object.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __abs__(self: array, /) -> array:
135135
136136
137137
.. note::
138-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.abs`.
138+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.abs`.
139139
"""
140140

141141
def __add__(self: array, other: Union[int, float, array], /) -> array:
@@ -181,7 +181,7 @@ def __add__(self: array, other: Union[int, float, array], /) -> array:
181181
182182
183183
.. note::
184-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.add`.
184+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.add`.
185185
"""
186186

187187
def __and__(self: array, other: Union[int, bool, array], /) -> array:
@@ -202,7 +202,7 @@ def __and__(self: array, other: Union[int, bool, array], /) -> array:
202202
203203
204204
.. note::
205-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_and`.
205+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_and`.
206206
"""
207207

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

240240
def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> PyCapsule:
241241
"""
242-
Exports the array for consumption by :func:`~signatures.creation_functions.from_dlpack` as a DLPack capsule.
242+
Exports the array for consumption by :func:`~array_api.from_dlpack` as a DLPack capsule.
243243
244244
Parameters
245245
----------
@@ -294,7 +294,7 @@ def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> P
294294

295295
def __dlpack_device__(self: array, /) -> Tuple[Enum, int]:
296296
"""
297-
Returns device type and device ID in DLPack format. Meant for use within :func:`~signatures.creation_functions.from_dlpack`.
297+
Returns device type and device ID in DLPack format. Meant for use within :func:`~array_api.from_dlpack`.
298298
299299
Parameters
300300
----------
@@ -336,7 +336,7 @@ def __eq__(self: array, other: Union[int, float, bool, array], /) -> array:
336336
337337
338338
.. note::
339-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.equal`.
339+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.equal`.
340340
"""
341341

342342
def __float__(self: array, /) -> float:
@@ -411,7 +411,7 @@ def __floordiv__(self: array, other: Union[int, float, array], /) -> array:
411411
412412
413413
.. note::
414-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.floor_divide`.
414+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.floor_divide`.
415415
"""
416416

417417
def __ge__(self: array, other: Union[int, float, array], /) -> array:
@@ -432,7 +432,7 @@ def __ge__(self: array, other: Union[int, float, array], /) -> array:
432432
433433
434434
.. note::
435-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.greater_equal`.
435+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.greater_equal`.
436436
"""
437437

438438
def __getitem__(self: array, key: Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], array], /) -> array:
@@ -470,7 +470,7 @@ def __gt__(self: array, other: Union[int, float, array], /) -> array:
470470
471471
472472
.. note::
473-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.greater`.
473+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.greater`.
474474
"""
475475

476476
def __index__(self: array, /) -> int:
@@ -522,7 +522,7 @@ def __invert__(self: array, /) -> array:
522522
523523
524524
.. note::
525-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_invert`.
525+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_invert`.
526526
"""
527527

528528
def __le__(self: array, other: Union[int, float, array], /) -> array:
@@ -543,7 +543,7 @@ def __le__(self: array, other: Union[int, float, array], /) -> array:
543543
544544
545545
.. note::
546-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.less_equal`.
546+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.less_equal`.
547547
"""
548548

549549
def __lshift__(self: array, other: Union[int, array], /) -> array:
@@ -564,7 +564,7 @@ def __lshift__(self: array, other: Union[int, array], /) -> array:
564564
565565
566566
.. note::
567-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_left_shift`.
567+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_left_shift`.
568568
"""
569569

570570
def __lt__(self: array, other: Union[int, float, array], /) -> array:
@@ -585,7 +585,7 @@ def __lt__(self: array, other: Union[int, float, array], /) -> array:
585585
586586
587587
.. note::
588-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.less`.
588+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.less`.
589589
"""
590590

591591
def __matmul__(self: array, other: array, /) -> array:
@@ -616,7 +616,7 @@ def __matmul__(self: array, other: array, /) -> array:
616616
617617
618618
.. note::
619-
Results must equal the results returned by the equivalent function :func:`~signatures.linear_algebra_functions.matmul`.
619+
Results must equal the results returned by the equivalent function :func:`~array_api.matmul`.
620620
621621
**Raises**
622622
@@ -676,7 +676,7 @@ def __mod__(self: array, other: Union[int, float, array], /) -> array:
676676
677677
678678
.. note::
679-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.remainder`.
679+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.remainder`.
680680
"""
681681

682682
def __mul__(self: array, other: Union[int, float, array], /) -> array:
@@ -715,7 +715,7 @@ def __mul__(self: array, other: Union[int, float, array], /) -> array:
715715
716716
717717
.. note::
718-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.multiply`.
718+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.multiply`.
719719
"""
720720

721721
def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:
@@ -736,7 +736,7 @@ def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:
736736
737737
738738
.. note::
739-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.not_equal`.
739+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.not_equal`.
740740
"""
741741

742742
def __neg__(self: array, /) -> array:
@@ -758,7 +758,7 @@ def __neg__(self: array, /) -> array:
758758
759759
760760
.. note::
761-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.negative`.
761+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.negative`.
762762
"""
763763

764764
def __or__(self: array, other: Union[int, bool, array], /) -> array:
@@ -779,7 +779,7 @@ def __or__(self: array, other: Union[int, bool, array], /) -> array:
779779
780780
781781
.. note::
782-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_or`.
782+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_or`.
783783
"""
784784

785785
def __pos__(self: array, /) -> array:
@@ -798,7 +798,7 @@ def __pos__(self: array, /) -> array:
798798
799799
800800
.. note::
801-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.positive`.
801+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.positive`.
802802
"""
803803

804804
def __pow__(self: array, other: Union[int, float, array], /) -> array:
@@ -853,7 +853,7 @@ def __pow__(self: array, other: Union[int, float, array], /) -> array:
853853
854854
855855
.. note::
856-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.pow`.
856+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.pow`.
857857
"""
858858

859859
def __rshift__(self: array, other: Union[int, array], /) -> array:
@@ -874,7 +874,7 @@ def __rshift__(self: array, other: Union[int, array], /) -> array:
874874
875875
876876
.. note::
877-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_right_shift`.
877+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_right_shift`.
878878
"""
879879

880880
def __setitem__(self: array, key: Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], array], value: Union[int, float, bool, array], /) -> None:
@@ -918,7 +918,7 @@ def __sub__(self: array, other: Union[int, float, array], /) -> array:
918918
919919
920920
.. note::
921-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.subtract`.
921+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.subtract`.
922922
"""
923923

924924
def __truediv__(self: array, other: Union[int, float, array], /) -> array:
@@ -971,7 +971,7 @@ def __truediv__(self: array, other: Union[int, float, array], /) -> array:
971971
972972
973973
.. note::
974-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.divide`.
974+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.divide`.
975975
"""
976976

977977
def __xor__(self: array, other: Union[int, bool, array], /) -> array:
@@ -992,7 +992,7 @@ def __xor__(self: array, other: Union[int, bool, array], /) -> array:
992992
993993
994994
.. note::
995-
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~signatures.elementwise_functions.bitwise_xor`.
995+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_xor`.
996996
"""
997997

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

10211021
array = _array
1022+
1023+
__all__ = ['array']

spec/API_specification/signatures/creation_functions.py renamed to spec/API_specification/array_api/creation_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def asarray(obj: Union[array, bool, int, float, NestedSequence, SupportsBufferPr
5454
.. admonition:: Note
5555
:class: note
5656
57-
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`.
57+
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.astype`.
5858
5959
.. note::
6060
If an input value exceeds the precision of the resolved output array data type, behavior is left unspecified and, thus, implementation-defined.

spec/API_specification/signatures/data_types.py renamed to spec/API_specification/array_api/data_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ def __eq__(self: dtype, other: dtype, /) -> bool:
1717
a boolean indicating whether the data type objects are equal.
1818
"""
1919

20-
all = [__eq__]
20+
__all__ = ['__eq__']

spec/API_specification/signatures/linalg.py renamed to spec/API_specification/array_api/linalg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def inv(x: array, /) -> array:
157157

158158
def matmul(x1: array, x2: array, /) -> array:
159159
"""
160-
Alias for :func:`~signatures.linear_algebra_functions.matmul`.
160+
Alias for :func:`~array_api.matmul`.
161161
"""
162162

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

250250
def matrix_transpose(x: array, /) -> array:
251251
"""
252-
Alias for :func:`~signatures.linear_algebra_functions.matrix_transpose`.
252+
Alias for :func:`~array_api.matrix_transpose`.
253253
"""
254254

255255
def outer(x1: array, x2: array, /) -> array:
@@ -406,7 +406,7 @@ def svdvals(x: array, /) -> array:
406406

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

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

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

446446
def vector_norm(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False, ord: Union[int, float, Literal[inf, -inf]] = 2) -> array:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy