Skip to content

Commit b4bc4a9

Browse files
docs: improve doctests for complex number instances in array/base/accessor-getter
PR-URL: stdlib-js#8644 Ref: stdlib-js#8641 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent f0f8a70 commit b4bc4a9

File tree

6 files changed

+12
-72
lines changed

6 files changed

+12
-72
lines changed

lib/node_modules/@stdlib/array/base/accessor-getter/README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,12 @@ Returns an accessor function for retrieving an element from an array-like object
4646

4747
```javascript
4848
var Complex64Array = require( '@stdlib/array/complex64' );
49-
var realf = require( '@stdlib/complex/float32/real' );
50-
var imagf = require( '@stdlib/complex/float32/imag' );
5149

5250
var arr = new Complex64Array( [ 1, 2, 3, 4 ] );
5351

5452
var get = accessorGetter( 'complex64' );
5553
var v = get( arr, 1 );
56-
// returns <Complex64>
57-
58-
var re = realf( v );
59-
// returns 3.0
60-
61-
var im = imagf( v );
62-
// returns 4.0
54+
// returns <Complex64>[ 3.0, 4.0 ]
6355
```
6456

6557
The returned accessor function accepts the following arguments:
@@ -104,14 +96,14 @@ var accessorGetter = require( '@stdlib/array/base/accessor-getter' );
10496

10597
var arr = new Complex128Array( zeroTo( 10 ) );
10698
var v = accessorGetter( dtype( arr ) )( arr, 2 );
107-
// returns <Complex128>
99+
// returns <Complex128>[ 4.0, 5.0 ]
108100

109101
console.log( v.toString() );
110102
// => '4 + 5i'
111103

112104
arr = new Complex64Array( zeroTo( 10 ) );
113105
v = accessorGetter( dtype( arr ) )( arr, 4 );
114-
// returns <Complex64>
106+
// returns <Complex64>[ 8.0, 9.0 ]
115107

116108
console.log( v.toString() );
117109
// => '8 + 9i'

lib/node_modules/@stdlib/array/base/accessor-getter/docs/repl.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@
4444
--------
4545
> var f = {{alias}}( 'complex64' );
4646
> var v = f( {{alias:@stdlib/array/complex64}}( [ 1, 2, 3, 4 ] ), 1 )
47-
<Complex64>
48-
> var r = {{alias:@stdlib/complex/float32/real}}( v )
49-
3.0
50-
> var i = {{alias:@stdlib/complex/float32/imag}}( v )
51-
4.0
47+
<Complex64>[ 3.0, 4.0 ]
5248

5349
See Also
5450
--------

lib/node_modules/@stdlib/array/base/accessor-getter/docs/types/index.d.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,12 @@ type GetArrayLike<T> = ( arr: AccessorArrayLike<T>, idx: number ) => T;
5858
*
5959
* @example
6060
* var Complex128Array = require( '@stdlib/array/complex128' );
61-
* var real = require( '@stdlib/array/real' );
62-
* var imag = require( '@stdlib/array/imag' );
6361
*
6462
* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );
6563
*
6664
* var get = getter( 'complex128' );
6765
* var v = get( arr, 1 );
68-
* // returns <Complex128>
69-
*
70-
* var re = real( v );
71-
* // returns 3.0
72-
*
73-
* var im = imag( v );
74-
* // returns 4.0
66+
* // returns <Complex128>[ 3.0, 4.0 ]
7567
*/
7668
declare function getter( dtype: 'complex128' ): GetComplex128;
7769

@@ -83,20 +75,12 @@ declare function getter( dtype: 'complex128' ): GetComplex128;
8375
*
8476
* @example
8577
* var Complex64Array = require( '@stdlib/array/complex64' );
86-
* var realf = require( '@stdlib/array/realf' );
87-
* var imagf = require( '@stdlib/array/imagf' );
8878
*
8979
* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );
9080
*
9181
* var get = getter( 'complex64' );
9282
* var v = get( arr, 1 );
93-
* // returns <Complex64>
94-
*
95-
* var re = realf( v );
96-
* // returns 3.0
97-
*
98-
* var im = imagf( v );
99-
* // returns 4.0
83+
* // returns <Complex64>[ 3.0, 4.0 ]
10084
*/
10185
declare function getter( dtype: 'complex64' ): GetComplex64;
10286

lib/node_modules/@stdlib/array/base/accessor-getter/examples/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ var accessorGetter = require( './../lib' );
2626

2727
var arr = new Complex128Array( zeroTo( 10 ) );
2828
var v = accessorGetter( dtype( arr ) )( arr, 2 );
29-
// returns <Complex128>
29+
// returns <Complex128>[ 4.0, 5.0 ]
3030

3131
console.log( '%s', v.toString() );
3232

3333
arr = new Complex64Array( zeroTo( 10 ) );
3434
v = accessorGetter( dtype( arr ) )( arr, 4 );
35-
// returns <Complex64>
35+
// returns <Complex64>[ 8.0, 9.0 ]
3636

3737
console.log( '%s', v.toString() );

lib/node_modules/@stdlib/array/base/accessor-getter/lib/index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,14 @@
2525
*
2626
* @example
2727
* var Complex64Array = require( '@stdlib/array/complex64' );
28-
* var realf = require( '@stdlib/complex/float32/real' );
29-
* var imagf = require( '@stdlib/complex/float32/imag' );
3028
* var dtype = require( '@stdlib/array/dtype' );
3129
* var getter = require( '@stdlib/array/base/accessor-getter' );
3230
*
3331
* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );
3432
*
3533
* var get = getter( dtype( arr ) );
3634
* var v = get( arr, 1 );
37-
* // returns <Complex64>
38-
*
39-
* var re = realf( v );
40-
* // returns 3.0
41-
*
42-
* var im = imagf( v );
43-
* // returns 4.0
35+
* // returns <Complex64>[ 3.0, 4.0 ]
4436
*/
4537

4638
// MODULES //

lib/node_modules/@stdlib/array/base/accessor-getter/lib/main.js

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,11 @@ var GETTERS = {
3939
*
4040
* @example
4141
* var Complex128Array = require( '@stdlib/array/complex128' );
42-
* var real = require( '@stdlib/complex/float64/real' );
43-
* var imag = require( '@stdlib/complex/float64/imag' );
4442
*
4543
* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );
4644
*
4745
* var v = getComplex128( arr, 1 );
48-
* // returns <Complex128>
49-
*
50-
* var re = real( v );
51-
* // returns 3.0
52-
*
53-
* var im = imag( v );
54-
* // returns 4.0
46+
* // returns <Complex128>[ 3.0, 4.0 ]
5547
*/
5648
function getComplex128( arr, idx ) {
5749
return arr.get( idx );
@@ -67,19 +59,11 @@ function getComplex128( arr, idx ) {
6759
*
6860
* @example
6961
* var Complex64Array = require( '@stdlib/array/complex64' );
70-
* var realf = require( '@stdlib/complex/float32/real' );
71-
* var imagf = require( '@stdlib/complex/float32/imag' );
7262
*
7363
* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );
7464
*
7565
* var v = getComplex64( arr, 1 );
76-
* // returns <Complex64>
77-
*
78-
* var re = realf( v );
79-
* // returns 3.0
80-
*
81-
* var im = imagf( v );
82-
* // returns 4.0
66+
* // returns <Complex64>[ 3.0, 4.0 ]
8367
*/
8468
function getComplex64( arr, idx ) {
8569
return arr.get( idx );
@@ -125,21 +109,13 @@ function getArrayLike( arr, idx ) {
125109
*
126110
* @example
127111
* var Complex64Array = require( '@stdlib/array/complex64' );
128-
* var realf = require( '@stdlib/complex/float32/real' );
129-
* var imagf = require( '@stdlib/complex/float32/imag' );
130112
* var dtype = require( '@stdlib/array/dtype' );
131113
*
132114
* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );
133115
*
134116
* var get = getter( dtype( arr ) );
135117
* var v = get( arr, 1 );
136-
* // returns <Complex64>
137-
*
138-
* var re = realf( v );
139-
* // returns 3.0
140-
*
141-
* var im = imagf( v );
142-
* // returns 4.0
118+
* // returns <Complex64>[ 3.0, 4.0 ]
143119
*/
144120
function getter( dtype ) {
145121
var f = GETTERS[ dtype ];

0 commit comments

Comments
 (0)