ndarray-pack
Advanced tools
Comparing version 0.0.1 to 1.0.0
"use strict" | ||
var ndarray = require("ndarray") | ||
var numeric = require("numeric") | ||
var cwise = require("cwise") | ||
@@ -18,10 +17,15 @@ | ||
module.exports = function convert(arr, dtype) { | ||
if(!dtype) { | ||
dtype = "float64" | ||
module.exports = function convert(arr) { | ||
var shape = [], c = arr, sz = 1 | ||
while(c instanceof Array) { | ||
shape.push(c.length) | ||
sz *= c.length | ||
c = c[0] | ||
} | ||
var shape = numeric.dim(arr) | ||
var result = ndarray.zeros(shape, dtype) | ||
if(shape.length === 0) { | ||
return ndarray([]) | ||
} | ||
var result = ndarray(new Float64Array(sz), shape) | ||
do_convert(result, arr) | ||
return result | ||
} | ||
} |
{ | ||
"name": "ndarray-pack", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "Packs an array-of-arrays into a single ndarray", | ||
@@ -10,5 +10,4 @@ "main": "convert.js", | ||
"dependencies": { | ||
"cwise": "~0.1.2", | ||
"ndarray": "~0.2.1", | ||
"numeric": "~1.2.6" | ||
"cwise": "~0.3.2", | ||
"ndarray": "~1.0.0" | ||
}, | ||
@@ -15,0 +14,0 @@ "devDependencies": { |
@@ -22,7 +22,6 @@ ndarray-pack | ||
### `require("ndarray-pack")(nested_array[, dtype])` | ||
### `require("ndarray-pack")(nested_array)` | ||
Converts the nested array into a packed ndarray. | ||
* `nested_array` is an array-of-arrays (ie a numeric.js array) | ||
* `dtype` is the data type of the packed ndarray. (Either, "uint8", "uint16", "uint32", "int8", "int16", "int32", "float" or "double") | ||
@@ -29,0 +28,0 @@ **Returns** A packed ndarray representation of the nested arrays. |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
44
1
3640
30
+ Addedcwise@0.3.4(transitive)
+ Addedcwise-compiler@0.0.0(transitive)
+ Addedcwise-parser@0.0.1(transitive)
+ Addediota-array@1.0.0(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedndarray@1.0.19(transitive)
+ Addeduniq@0.0.2(transitive)
- Removednumeric@~1.2.6
- Removedcwise@0.1.2(transitive)
- Removedfalafel@0.1.6(transitive)
- Removedndarray@0.2.4(transitive)
- Removednumeric@1.2.6(transitive)
Updatedcwise@~0.3.2
Updatedndarray@~1.0.0