mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Add typings for ndarray (#12208)
* Add typings for ndarray * [ndarray] Fix indentation * [ndarray] Make test be passed with strictNullChecks=true
This commit is contained in:
committed by
Mohamed Hegazy
parent
da09b3d1a0
commit
5d8373707c
25
ndarray/ndarray-tests.ts
Normal file
25
ndarray/ndarray-tests.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import ndarray = require('ndarray');
|
||||
|
||||
const data = new Int32Array(2 * 2 * 2 + 10);
|
||||
const a = ndarray(data, [2, 2, 2], [1, 2, 4], 5);
|
||||
|
||||
console.log(a.data === data);
|
||||
console.log(a.shape[0] === 2);
|
||||
console.log(a.shape[1] === 2);
|
||||
console.log(a.shape[2] === 2);
|
||||
console.log(a.stride[0] === 1);
|
||||
console.log(a.stride[1] === 2);
|
||||
console.log(a.stride[2] === 4);
|
||||
console.log(a.offset === 5);
|
||||
console.log(a.dtype === 'int32');
|
||||
console.log(a.size === 8);
|
||||
console.log(a.order[0] === 0);
|
||||
console.log(a.order[1] === 1);
|
||||
console.log(a.order[2] === 2);
|
||||
console.log(a.dimension === 3);
|
||||
console.log(a.set(0, 0, 0, 1) === 1);
|
||||
console.log(a.get(0, 0, 0) === 1);
|
||||
console.log(a.index(1, 1, 1) === 12);
|
||||
|
||||
const b = a.lo(0, 0, 0).hi(1, 1, 1);
|
||||
const c = b.step(0).transpose(0, 0, 0).pick(-1, -1, 0);
|
||||
Reference in New Issue
Block a user