8000 Add cross-reference targets to all the function, method, constant, an… · tonyfast/array-api@8581a32 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8581a32

Browse files
committed
Add cross-reference targets to all the function, method, constant, and attribute definitions
This will make it easier to parse for the test suite.
1 parent ca60e8c commit 8581a32

11 files changed

+146
-0
lines changed

spec/API_specification/array_object.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ For the expected numerical behaviour, see their left-hand equivalents.
179179

180180
<!-- NOTE: please keep the attributes in alphabetical order -->
181181

182+
(attribute-dtype)=
182183
### dtype
183184

184185
Data type of the array elements.
@@ -189,6 +190,7 @@ Data type of the array elements.
189190

190191
- array data type.
191192

193+
(attribute-ndim)=
192194
### ndim
193195

194196
Number of array dimensions (axes).
@@ -201,6 +203,7 @@ Number of array dimensions (axes).
201203

202204
_TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where the number of dimensions may be dynamic._
203205

206+
(attribute-shape)=
204207
### shape
205208

206209
Array dimensions.
@@ -213,6 +216,7 @@ Array dimensions.
213216

214217
_TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where a shape may be dynamic._
215218

219+
(attribute-size)=
216220
### size
217221

218222
Number of elements in an array. This should equal the product of the array's dimensions.
@@ -225,6 +229,7 @@ Number of elements in an array. This should equal the product of the array's dim
225229

226230
_TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where the number of elements may be dynamic._
227231

232+
(attribute-T)=
228233
### T
229234

230235
Transpose of the array.
@@ -241,6 +246,7 @@ Transpose of the array.
241246

242247
<!-- NOTE: please keep the methods in alphabetical order -->
243248

249+
(method-__abs__)=
244250
### \_\_abs\_\_(x, /)
245251

246252
Calculates the absolute value for each element `x_i` of an array instance `x` (i.e., the element-wise result has the same magnitude as the respective element in `x` but has positive sign).
@@ -268,6 +274,7 @@ Calculates the absolute value for each element `x_i` of an array instance `x` (i
268274
Element-wise results must equal the results returned by the equivalent element-wise function [`abs(x)`](elementwise_functions.md#absx-).
269275
```
270276

277+
(method-__add__)=
271278
### \_\_add\_\_(x1, x2, /)
272279

273280
Calculates the sum for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`. For floating-point arithmetic,
@@ -318,6 +325,7 @@ Floating-point addition is a commutative operation, but not always associative.
318325
Element-wise results must equal the results returned by the equivalent element-wise function [`add(x1, x2)`](elementwise_functions.md#addx1-x2-).
319326
```
320327

328+
(method-__and__)=
321329
### \_\_and\_\_(x1, x2, /)
322330

323331
Evaluates `x1_i & x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -343,6 +351,7 @@ Evaluates `x1_i & x2_i` for each element `x1_i` of an array instance `x1` with t
343351
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_and(x1, x2)`](elementwise_functions.md#logical_andx1-x2-).
344352
`` 9E88 `
345353

354+
(method-__eq__)=
346355
### \_\_eq\_\_(x1, x2, /)
347356

348357
Computes the truth value of `x1_i == x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -368,6 +377,7 @@ Computes the truth value of `x1_i == x2_i` for each element `x1_i` of an array i
368377
Element-wise results must equal the results returned by the equivalent element-wise function [`equal(x1, x2)`](elementwise_functions.md#equalx1-x2-).
369378
```
370379

380+
(method-__floordiv__)=
371381
### \_\_floordiv\_\_(x1, x2, /)
372382

373383
Evaluates `x1_i // x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -393,6 +403,7 @@ Evaluates `x1_i // x2_i` for each element `x1_i` of an array instance `x1` with
393403
Element-wise results must equal the results returned by the equivalent element-wise function [`floor_divide(x1, x2)`](elementwise_functions.md#floor_dividex1-x2-).
394404
```
395405

406+
(method-__ge__)=
396407
### \_\_ge\_\_(x1, x2, /)
397408

398409
Computes the truth value of `x1_i >= x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -418,10 +429,12 @@ Computes the truth value of `x1_i >= x2_i` for each element `x1_i` of an array i
418429
Element-wise results must equal the results returned by the equivalent element-wise function [`greater_equal(x1, x2)`](elementwise_functions.md#greater_equalx1-x2-).
419430
```
420431

432+
(method-__getitem__)=
421433
### \_\_getitem\_\_(x, key, /)
422434

423435
_TODO: dependent on the indexing specification._
424436

437+
(method-__gt__)=
425438
### \_\_gt\_\_(x1, x2, /)
426439

427440
Computes the truth value of `x1_i > x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -447,6 +460,7 @@ Computes the truth value of `x1_i > x2_i` for each element `x1_i` of an array in
447460
Element-wise results must equal the results returned by the equivalent element-wise function [`greater(x1, x2)`](elementwise_functions.md#greaterx1-x2-).
448461
```
449462

463+
(method-__invert__)=
450464
### \_\_invert\_\_(x, /)
451465

452466
Evaluates `~x_i` for each element `x_i` of an array instance `x`.
@@ -468,6 +482,7 @@ Evaluates `~x_i` for each element `x_i` of an array instance `x`.
468482
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_invert(x)`](elementwise_functions.md#bitwise_invertx-).
469483
```
470484

485+
(method-__le__)=
471486
### \_\_le\_\_(x1, x2, /)
472487

473488
Computes the truth value of `x1_i <= x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -493,10 +508,12 @@ Computes the truth value of `x1_i <= x2_i` for each element `x1_i` of an array i
493508
Element-wise results must equal the results returned by the equivalent element-wise function [`less_equal(x1, x2)`](elementwise_functions.md#less_equalx1-x2-).
494509
```
495510

511+
(method-__len__)=
496512
### \_\_len\_\_(x, /)
497513

498514
_TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where a shape may be dynamic._
499515

516+
(method-__lshift__)=
500517
### \_\_lshift\_\_(x1, x2, /)
501518

502519
Evaluates `x1_i << x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -522,6 +539,7 @@ Evaluates `x1_i << x2_i` for each element `x1_i` of an array instance `x1` with
522539
Element-wise results must equal the results returned by the equivalent element-wise function [`less_equal(x1, x2)`](elementwise_functions.md#bitwise_left_shiftx1-x2-).
523540
```
524541

542+
(method-__lt__)=
525543
### \_\_lt\_\_(x1, x2, /)
526544

527545
Computes the truth value of `x1_i < x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -547,6 +565,7 @@ Computes the truth value of `x1_i < x2_i` for each element `x1_i` of an array in
547565
Element-wise results must equal the results returned by the equivalent element-wise function [`less(x1, x2)`](elementwise_functions.md#lessx1-x2-).
548566
```
549567

568+
(method-__matmul__)=
550569
### \_\_matmul\_\_(x1, x2, /)
551570

552571
_TODO: awaiting `matmul` functional equivalent._
@@ -567,6 +586,7 @@ _TODO: awaiting `matmul` functional equivalent._
567586

568587
- _TODO_
569588

589+
(method-__mod__)=
570590
### \_\_mod\_\_(x1, x2, /)
571591

572592
Evaluates `x1_i % x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -592,6 +612,7 @@ Evaluates `x1_i % x2_i` for each element `x1_i` of an array instance `x1` with t
592612
Element-wise results must equal the results returned by the equivalent element-wise function [`remainder(x1, x2)`](elementwise_functions.md#remainderx1-x2-).
593613
```
594614

615+
(method-__mul__)=
595616
### \_\_mul\_\_(x1, x2, /)
596617

597618
Calculates the product for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`. For floating-point arithmetic,
@@ -634,6 +655,7 @@ Floating-point multiplication is not always associative due to finite precision.
634655
Element-wise results must equal the results returned by the equivalent element-wise function [`multiply(x1, x2)`](elementwise_functions.md#multiplyx1-x2-).
635656
```
636657

658+
(method-__ne__)=
637659
### \_\_ne\_\_(x1, x2, /)
638660

639661
Computes the truth value of `x1_i != x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -659,6 +681,7 @@ Computes the truth value of `x1_i != x2_i` for each element `x1_i` of an array i
659681
Element-wise results must equal the results returned by the equivalent element-wise function [`not_equal(x1, x2)`](elementwise_functions.md#not_equalx1-x2-).
660682
```
661683

684+
(method-__neg__)=
662685
### \_\_neg\_\_(x, /)
663686

664687
Evaluates `-x_i` for each element `x_i` of an array instance `x`.
@@ -680,6 +703,7 @@ Evaluates `-x_i` for each element `x_i` of an array instance `x`.
680703
Element-wise results must equal the results returned by the equivalent element-wise function [`negative(x)`](elementwise_functions.md#negativex-).
681704
```
682705

706+
(method-__or__)=
683707
### \_\_or\_\_(x1, x2, /)
684708

685709
Evaluates `x1_i | x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -705,6 +729,7 @@ Evaluates `x1_i | x2_i` for each element `x1_i` of an array instance `x1` with t
705729
Element-wise results must equal the results returned by the equivalent element-wise function [`positive(x1, x2)`](elementwise_functions.md#bitwise_orx1-x2-).
706730
```
707731

732+
(method-__pos__)=
708733
### \_\_pos\_\_(x, /)
709734

710735
Evaluates `+x_i` for each element `x_i` of an array instance `x`.
@@ -726,6 +751,7 @@ Evaluates `+x_i` for each element `x_i` of an array instance `x`.
726751
Element-wise results must equal the results returned by the equivalent element-wise function [`positive(x)`](elementwise_functions.md#positivex-).
727752
```
728753

754+
(method-__pow__)=
729755
### \_\_pow\_\_(x1, x2, /)
730756

731757
Calculates an implementation-dependent approximation of exponentiation by raising each element `x1_i` (the base) of an array instance `x1` to the power of `x2_i` (the exponent), where `x2_i` is the corresponding element of the array `x2`.
@@ -778,6 +804,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin
778804
Element-wise results must equal the results returned by the equivalent element-wise function [`pow(x1, x2)`](elementwise_functions.md#powx1-x2-).
779805
```
780806

807+
(method-__rshift__)=
781808
### \_\_rshift\_\_(x1, x2, /)
782809

783810
Evaluates `x1_i >> x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -803,10 +830,12 @@ Evaluates `x1_i >> x2_i` for each element `x1_i` of an array instance `x1` with
803830
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_right_shift(x1, x2)`](elementwise_functions.md#bitwise_right_shiftx1-x2-).
804831
```
805832

833+
(method-__setitem__)=
806834
### \_\_setitem\_\_(x, key, value, /)
807835

808836
_TODO: dependent on the indexing specification._
809837

838+
(method-__sub__)=
810839
### \_\_sub\_\_(x1, x2, /)
811840

812841
Calculates the difference for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`. The result of `x1_i - x2_i` must be the same as `x1_i + (-x2_i)` and is thus governed by the same floating-point rules as addition (see [`__add__()`](#__add__x1-x2-)).
@@ -832,6 +861,7 @@ Calculates the difference for each element `x1_i` of an array instance `x1` with
832861
Element-wise results must equal the results returned by the equivalent element-wise function [`subtract(x1, x2)`](elementwise_functions.md#subtractx1-x2-).
833862
```
834863

864+
(method-__truediv__)=
835865
### \_\_truediv\_\_(x1, x2, /)
836866

837867
Evaluates `x1_i / x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`. For floating-point arithmetic,
@@ -882,6 +912,7 @@ Evaluates `x1_i / x2_i` for each element `x1_i` of an array instance `x1` with t
882912
Element-wise results must equal the results returned by the equivalent element-wise function [`divide(x1, x2)`](elementwise_functions.md#dividex1-x2-).
883913
```
884914

915+
(method-__xor__)=
885916
### \_\_xor\_\_(x1, x2, /)
886917

887918
Evaluates `x1_i ^ x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.

spec/API_specification/constants.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ A conforming implementation of the array API standard must provide and support t
88

99
## Objects in API
1010

11+
(constant-e)=
1112
### e
1213

1314
Euler's constant.
@@ -16,14 +17,17 @@ Euler's constant.
1617
e = 2.71828182845904523536028747135266249775724709369995...
1718
```
1819

20+
(constant-inf)=
1921
### inf
2022

2123
IEEE 754 floating point representation of (positive) infinity.
2224

25+
(constant-nan)=
2326
### nan
2427

2528
IEEE 754 floating point representation of Not a Number (`NaN`).
2629

30+
(constant-pi)=
2731
### pi
2832

2933
The mathematical constant `π`.

spec/API_specification/creation_functions.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ A conforming implementation of the array API standard must provide and support t
1111

1212
<!-- NOTE: please keep the functions in alphabetical order -->
1313

14+
(function-arange)=
1415
### arange(start, /, *, stop=None, step=1, dtype=None)
1516

1617
Returns evenly spaced values within the half-open interval `[start, stop)` as a one-dimensional array.
@@ -44,6 +45,7 @@ This function cannot guarantee that the interval does not include the `stop` val
4445

4546
- a one-dimensional array containing evenly spaced values. The length of the output array must be `ceil((stop-start)/step)`.
4647

48+
(function-empty)=
4749
### empty(shape, /, *, dtype=None)
4850

4951
Returns an uninitialized array having a specified `shape`.
@@ -64,6 +66,7 @@ Returns an uninitialized array having a specified `shape`.
6466

6567
- an array containing uninitialized data.
6668

69+
(function-empty_like)=
6770
### empty_like(x, /, *, dtype=None)
6871

6972
Returns an uninitialized array with the same `shape` as an input array `x`.
@@ -84,6 +87,7 @@ Returns an uninitialized array with the same `shape` as an input array `x`.
8487

8588
- an array having the same shape as `x` and containing uninitialized data.
8689

90+
(function-eye)=
8791
### eye(N, /, *, M=None, k=0, dtype=None)
8892

8993
Returns a two-dimensional array with ones on the `k`th diagonal and zeros elsewhere.
@@ -112,6 +116,7 @@ Returns a two-dimensional array with ones on the `k`th diagonal and zeros elsewh
112116

113117
- an array where all elements are equal to zero, except for the `k`th diagonal, whose values are equal to one.
114118

119+
(function-full)=
115120
### full(shape, fill_value, /, *, dtype=None)
116121

117122
Returns a new array having a specified `shape` and filled with `fill_value`.
@@ -136,6 +141,7 @@ Returns a new array having a specified `shape` and filled with `fill_value`.
136141

137142
- an array where every element is equal to `fill_value`.
138143

144+
(function-full_like)=
139145
### full_like(x, fill_value, /, *, dtype=None)
140146

141147
Returns a new array filled with `fill_value` and having the same `shape` as an input array `x`.
@@ -160,6 +166,7 @@ Returns a new array filled with `fill_value` and having the same `shape` as an i
160166

161167
- an array having the same shape as `x` and where every element is equal to `fill_value`.
162168

169+
(function-linspace)=
163170
### linspace(start, stop, num, /, *, dtype=None, endpoint=True)
164171

165172
Returns evenly spaced numbers over a specified interval.
@@ -194,6 +201,7 @@ Returns evenly spaced numbers over a specified interval.
194201

195202
- a one-dimensional array containing evenly spaced values.
196203

204+
(function-ones)=
197205
### ones(shape, /, *, dtype=None)
198206

199207
Returns a new array having a specified `shape` and filled with ones.
@@ -214,6 +222,7 @@ Returns a new array having a specified `shape` and filled with ones.
214222

215223
- an array containing ones.
216224

225+
(function-ones_like)=
217226
### ones_like(x, /, *, dtype=None)
218227

219228
Returns a new array filled with ones and having the same `shape` as an input array `x`.
@@ -234,6 +243,7 @@ Returns a new array filled with ones and having the same `shape` as an input arr
234243

235244
- an array having the same shape as `x` and filled with ones.
236245

246+
(function-zeros)=
237247
### zeros(shape, /, *, dtype=None)
238248

239249
Returns a new array having a specified `shape` and filled with zeros.
@@ -254,6 +264,7 @@ Returns a new array having a specified `shape` and filled with zeros.
254264

255265
- an array containing zeros.
256266

267+
(function-zeros_like)=
257268
### zeros_like(x, /, *, dtype=None)
258269

259270
Returns a new array filled with zeros and having the same `shape` as an input array `x`.

0 commit comments

Comments
 (0)
0