Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

numjs

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

numjs - npm Package Compare versions

Comparing version 0.14.2 to 0.15.0

4

package.json
{
"name": "numjs",
"version": "0.14.2",
"version": "0.15.0",
"description": "Like NumPy, in JavaScript",

@@ -58,3 +58,3 @@ "main": "src/index.js",

"preversion": "grunt test && git ci dist -m 'bump version' --allow-empty ",
"postversion": "npm publish"
"postversion": "npm publish && grunt doc"
},

@@ -61,0 +61,0 @@ "repository": {

@@ -633,2 +633,24 @@ [![Build Status](https://travis-ci.org/nicolaspanel/numjs.png)](https://travis-ci.org/nicolaspanel/numjs) [![npm version](https://badge.fury.io/js/numjs.svg)](https://badge.fury.io/js/numjs) [![Bower version](https://badge.fury.io/bo/numjs.svg)](https://badge.fury.io/bo/numjs) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.svg)](http://gruntjs.com/)

### Other utils
`rot90`
```js
> m = nj.array([[1,2],[3,4]], 'int')
> m
array([[1, 2],
[3, 4]])
> nj.rot90(m)
array([[2, 4],
[1, 3]])
> nj.rot90(m, 2)
array([[4, 3],
[2, 1]])
> m = nj.arange(8).reshape([2,2,2])
> nj.rot90(m, 1, [1,2])
array([[[1, 3],
[0, 2]],
[[5, 7],
[4, 6]]])
```
## Images manipulation

@@ -635,0 +657,0 @@ __NumJs__’s comes with powerful functions for image processing. Theses function are located in `nj.images` module.

@@ -717,2 +717,67 @@ 'use strict';

/**
* Reverse the order of elements in an array along the given axis.
* The shape of the array is preserved, but the elements are reordered.
* New in version 0.15.0.
* @param {Array|NdArray} m Input array.
* @param {number} axis Axis in array, which entries are reversed.
* @return {NdArray} A view of `m` with the entries of axis reversed. Since a view is returned, this operation is done in constant time.
*/
function flip(m, axis) {
m = NdArray.new(m);
var indexer = ones(m.ndim).tolist();
var cleanaxis = axis;
while (cleanaxis < 0) {
cleanaxis += m.ndim;
}
if (indexer[cleanaxis] === undefined) {
throw new errors.ValueError('axis=' + axis + 'invalid for the ' + m.ndim + '-dimensional input array');
}
indexer[cleanaxis] = -1;
return m.step.apply(m, indexer);
}
/**
* Rotate an array by 90 degrees in the plane specified by axes.
* Rotation direction is from the first towards the second axis.
* New in version 0.15.0.
* @param {Array|NdArray} m array_like
* @param {number} [k=1] Number of times the array is rotated by 90 degrees.
* @param {Array|NdArray} [axes=(0,1)] The array is rotated in the plane defined by the axes. Axes must be different.
* @return {NdArray} A rotated view of m.
*/
function rot90 (m, k, axes) {
k = k || 1;
while (k < 0) {
k += 4;
}
k = k % 4;
m = NdArray.new(m);
axes = NdArray.new(axes || [0, 1]);
if (axes.shape.length !== 1 || axes.shape[0] !== 2) {
throw new errors.ValueError('len(axes) must be 2');
}
axes = axes.tolist();
if (axes[0] === axes[1] || abs(axes[0] - axes[1]) === m.ndim) {
throw new errors.ValueError("Axes must be different.")
}
if (k === 0) {
return m;
}
if (k === 2) {
return flip(flip(m, axes[0]), axes[1]);
}
var axesList = arange(m.ndim).tolist();
var keep = axesList[axes[0]];
axesList[axes[0]] = axesList[axes[1]];
axesList[axes[1]] = keep;
if (k === 1) {
return transpose(flip(m, axes[1]), axesList);
} else {
return flip(transpose(m, axesList), axes[1]);
}
}
module.exports = {

@@ -730,2 +795,3 @@ config: CONF,

flatten: flatten,
flip: flip,
random: random,

@@ -772,2 +838,3 @@ softmax: softmax,

stack: stack,
rot90: rot90,
int8: function (array) { return NdArray.new(array, 'int8'); },

@@ -774,0 +841,0 @@ uint8: function (array) { return NdArray.new(array, 'uint8'); },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc