Skip to content

Commit 3e88dac

Browse files
committed
Merge with main
2 parents cef078e + e059ae2 commit 3e88dac

File tree

11 files changed

+1445
-55
lines changed

11 files changed

+1445
-55
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ build/
33
.vscode/
44
node_modules/
55
__pycache__/
6-
*.pyc
6+
*.pyc
7+
spec/**/generated

spec/API_specification/array_object.md

Lines changed: 1357 additions & 0 deletions
Large diffs are not rendered by default.

spec/API_specification/constants.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

spec/API_specification/constants.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Constants
2+
=========
3+
4+
Array API specification for constants.
5+
6+
A conforming implementation of the array API standard must provide and support the following constants adhering to the following conventions.
7+
8+
- Each constant must have a Python floating-point data type (i.e., ``float``) and be provided as a Python scalar value.
9+
10+
Objects in API
11+
--------------
12+
13+
.. currentmodule:: signatures.constants
14+
15+
..
16+
NOTE: please keep the functions in alphabetical order
17+
18+
.. autosummary::
19+
:toctree: generated
20+
21+
e
22+
inf
23+
nan
24+
pi

spec/API_specification/elementwise_functions.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ For floating-point operands,
528528

529529
Calculates the division for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.
530530

531+
```{note}
532+
If one or both of the input arrays have integer data types, the result is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
533+
534+
Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, the array must have a floating-point data type.
535+
```
536+
531537
#### Special Cases
532538

533539
For floating-point operands,
@@ -1223,7 +1229,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin
12231229
```{note}
12241230
If both `x1` and `x2` have integer data types, the result of `pow` when `x2_i` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
12251231
1226-
If `x1` has an integer data type and `x2` has a floating-point data type, behavior is implementation-dependent (type promotion between data type "kinds" (integer versus floating-point) is unspecified).
1232+
If `x1` has an integer data type and `x2` has a floating-point data type, behavior is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
12271233
```
12281234

12291235
#### Special Cases

spec/API_specification/index.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ API specification
77
:caption: API specification
88
:maxdepth: 3
99

10-
function_and_method_signatures
1110
array_object
12-
indexing
13-
data_types
14-
data_type_functions
15-
type_promotion
1611
broadcasting
12+
constants
1713
creation_functions
18-
manipulation_functions
14+
data_type_functions
15+
data_types
1916
elementwise_functions
20-
statistical_functions
17+
function_and_method_signatures
18+
indexing
2119
linear_algebra_functions
20+
manipulation_functions
2221
searching_functions
23-
sorting_functions
2422
set_functions
23+
sorting_functions
24+
statistical_functions
25+
type_promotion
2526
utility_functions
26-
constants

spec/API_specification/signatures/array_object.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ def __pow__(self: array, other: Union[int, float, array], /) -> array:
761761
Notes
762762
-----
763763
- If both ``self`` and ``other`` have integer data types, the result of ``__pow__`` when `other_i` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
764-
- If ``self`` has an integer data type and ``other`` has a floating-point data type, behavior is implementation-dependent (type promotion between data type "kinds" (integer versus floating-point) is unspecified).
764+
- If ``self`` has an integer data type and ``other`` has a floating-point data type, behavior is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
765765
- Element-wise results must equal the results returned by the equivalent element-wise function :ref:`function-pow`.
766766
767767
**Special cases**
@@ -875,6 +875,8 @@ def __truediv__(self: array, other: Union[int, float, array], /) -> array:
875875
Notes
876876
-----
877877
- Element-wise results must equal the results returned by the equivalent element-wise function :ref:`function-divide`.
878+
- If one or both of ``self`` and ``other`` have integer data types, the result is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
879+
- Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, the array must have a floating-point data type.
878880
879881
**Special cases**
880882
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
e = 2.718281828459045
2+
"""
3+
IEEE 754 floating-point representation of Euler's constant.
4+
5+
``e = 2.71828182845904523536028747135266249775724709369995...``
6+
"""
7+
8+
inf = float('inf')
9+
"""
10+
IEEE 754 floating-point representation of (positive) infinity.
11+
"""
12+
13+
nan = float('nan')
14+
"""
15+
IEEE 754 floating-point representation of Not a Number (``NaN``).
16+
"""
17+
18+
pi = 3.141592653589793
19+
"""
20+
IEEE 754 floating-point representation of the mathematical constant ``π``.
21+
22+
``pi = 3.1415926535897932384626433...``
23+
"""
24+
25+
__all__ = ['e', 'inf', 'nan', 'pi']

spec/API_specification/statistical_functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A conforming implementation of the array API standard must provide and support t
2121
Calculates the maximum value of the input array `x`.
2222

2323
```{note}
24-
When the number of elements over which to compute the maximum value is zero, the maximum value is implementation-defined. Specification-compliant libraries may choose to error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the minimum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `-infinity`).
24+
When the number of elements over which to compute the maximum value is zero, the maximum value is implementation-defined. Specification-compliant libraries may choose to raise an error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the minimum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `-infinity`).
2525
```
2626

2727
#### Special Cases
@@ -92,7 +92,7 @@ Let `N` equal the number of elements over which to compute the arithmetic mean.
9292
Calculates the minimum value of the input array `x`.
9393
9494
```{note}
95-
When the number of elements over which to compute the minimum value is zero, the minimum value is implementation-defined. Specification-compliant libraries may choose to error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the maximum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `+infinity`).
95+
When the number of elements over which to compute the minimum value is zero, the minimum value is implementation-defined. Specification-compliant libraries may choose to raise an error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the maximum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `+infinity`).
9696
```
9797

9898
#### Special Cases

spec/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ BUILDDIR = _build
1212
help:
1313
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1414

15-
.PHONY: help Makefile
15+
.PHONY: help Makefile clean
1616

1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
2020
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21+
22+
clean:
23+
-rm -rf $(BUILDDIR)
24+
-rm -rf "$(SOURCEDIR)/API_specification/generated"

spec/conf.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
add_module_names = False
4848
napoleon_custom_sections = [('Returns', 'params_style')]
4949

50+
# Make autosummary show the signatures of functions in the tables using actual
51+
# Python syntax. There's currently no supported way to do this, so we have to
52+
# just patch out the function that processes the signatures. See
53+
# https://github.com/sphinx-doc/sphinx/issues/10053.
54+
import sphinx.ext.autosummary as autosummary_mod
55+
if hasattr(autosummary_mod, '_module'):
56+
# It's a sphinx deprecated module wrapper object
57+
autosummary_mod = autosummary_mod._module
58+
autosummary_mod.mangle_signature = lambda sig, max_chars=30: sig
59+
5060
# Add any paths that contain templates here, relative to this directory.
5161
templates_path = ['_templates']
5262

@@ -162,4 +172,4 @@ def process_signature(app, what, name, obj, options, signature, return_annotatio
162172
return signature, return_annotation
163173

164174
def setup(app):
165-
app.connect("autodoc-process-signature", process_signature)
175+
app.connect("autodoc-process-signature", process_signature)

0 commit comments

Comments
 (0)