Skip to content

Commit 934e2fc

Browse files
committed
feat: improve type specificity
1 parent 76fedac commit 934e2fc

File tree

2 files changed

+10
-44
lines changed

2 files changed

+10
-44
lines changed

lib/node_modules/@stdlib/blas/ddot/docs/types/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { ndarray } from '@stdlib/types/ndarray';
23+
import { float64ndarray } from '@stdlib/types/ndarray';
2424

2525
/**
2626
* Computes the dot product of two double-precision floating-point vectors.
@@ -33,16 +33,16 @@ import { ndarray } from '@stdlib/types/ndarray';
3333
* @returns dot product
3434
*
3535
* @example
36-
* var Float64Array = require( `@stdlib/array/float64` );
37-
* var array = require( `@stdlib/ndarray/array` );
36+
* var Float64Array = require( '@stdlib/array/float64' );
37+
* var array = require( '@stdlib/ndarray/array' );
3838
*
3939
* var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
4040
* var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
4141
*
4242
* var z = ddot( x, y );
4343
* // returns -5.0
4444
*/
45-
declare function ddot( x: ndarray, y: ndarray ): number;
45+
declare function ddot( x: float64ndarray, y: float64ndarray ): number;
4646

4747

4848
// EXPORTS //

lib/node_modules/@stdlib/blas/ddot/docs/types/test.ts

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,20 @@
1616
* limitations under the License.
1717
*/
1818

19-
/// <reference types="@stdlib/types"/>
20-
21-
import { ndarray } from '@stdlib/types/ndarray';
19+
import zeros = require( '@stdlib/ndarray/zeros' );
2220
import ddot = require( './index' );
2321

24-
/**
25-
* Returns an ndarray object.
26-
*
27-
* @returns ndarray object
28-
*/
29-
function createArray(): ndarray {
30-
const arr: ndarray = {
31-
'byteLength': null,
32-
'BYTES_PER_ELEMENT': null,
33-
'data': new Float64Array( [ 1, 2, 3 ] ),
34-
'dtype': 'float64',
35-
'flags': {
36-
'ROW_MAJOR_CONTIGUOUS': true,
37-
'COLUMN_MAJOR_CONTIGUOUS': false
38-
},
39-
'length': 3,
40-
'ndims': 1,
41-
'offset': 0,
42-
'order': 'row-major',
43-
'shape': [ 3 ],
44-
'strides': [ 1 ],
45-
'get': ( i: number ): any => {
46-
return arr.data[ i ];
47-
},
48-
'set': ( i: number, v: any ): ndarray => {
49-
arr.data[ i ] = v;
50-
return arr;
51-
}
52-
};
53-
return arr;
54-
}
55-
5622

5723
// TESTS //
5824

5925
// The function returns a number...
6026
{
61-
ddot( createArray(), createArray() ); // $ExpectType number
27+
ddot( zeros( [ 10 ] ), zeros( [ 10 ] ) ); // $ExpectType number
6228
}
6329

6430
// The compiler throws an error if the function is provided a first argument which is not an ndarray...
6531
{
66-
const y: ndarray = createArray();
32+
const y = zeros( [ 10 ] );
6733

6834
ddot( 10, y ); // $ExpectError
6935
ddot( '10', y ); // $ExpectError
@@ -78,7 +44,7 @@ function createArray(): ndarray {
7844

7945
// The compiler throws an error if the function is provided a second argument which is not an ndarray...
8046
{
81-
const x: ndarray = createArray();
47+
const x = zeros( [ 10 ] );
8248

8349
ddot( x, 10 ); // $ExpectError
8450
ddot( x, '10' ); // $ExpectError
@@ -93,8 +59,8 @@ function createArray(): ndarray {
9359

9460
// The compiler throws an error if the function is provided an unsupported number of arguments...
9561
{
96-
const x: ndarray = createArray();
97-
const y: ndarray = createArray();
62+
const x = zeros( [ 10 ] );
63+
const y = zeros( [ 10 ] );
9864

9965
ddot(); // $ExpectError
10066
ddot( x ); // $ExpectError

0 commit comments

Comments
 (0)