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:
Giff Song
2016-10-26 03:39:18 +09:00
committed by Mohamed Hegazy
parent da09b3d1a0
commit 5d8373707c
3 changed files with 78 additions and 0 deletions

25
ndarray/ndarray-tests.ts Normal file
View 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);