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

dstructs-matrix

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dstructs-matrix - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

lib/get.js

@@ -21,3 +21,3 @@ 'use strict';

if ( !isNonNegativeInteger( i ) || !isNonNegativeInteger( j ) ) {
throw new TypeError( 'get()::invalid input argument. Indices must be nonnegative integers. Values: `[' + i + ','+ j + ']`.' );
throw new TypeError( 'invalid input argument. Indices must be nonnegative integers. Values: `[' + i + ','+ j + ']`.' );
}

@@ -24,0 +24,0 @@ return this.data[ this.offset + i*this.strides[0] + j*this.strides[1] ];

@@ -21,3 +21,3 @@ 'use strict';

if ( !isInteger( idx ) ) {
throw new TypeError( 'iget()::invalid input argument. Must provide a integer. Value: `' + idx + '`.' );
throw new TypeError( 'invalid input argument. Must provide a integer. Value: `' + idx + '`.' );
}

@@ -24,0 +24,0 @@ if ( idx < 0 ) {

@@ -6,2 +6,3 @@ 'use strict';

var isInteger = require( 'validate.io-integer-primitive' ),
isnan = require( 'validate.io-nan' ),
isNumber = require( 'validate.io-number-primitive' );

@@ -24,6 +25,6 @@

if ( !isInteger( idx ) ) {
throw new TypeError( 'iset()::invalid input argument. An index must be an integer. Value: `' + idx + '`.' );
throw new TypeError( 'invalid input argument. An index must be an integer. Value: `' + idx + '`.' );
}
if ( !isNumber( v ) ) {
throw new TypeError( 'iset()::invalid input argument. An input value must be a number primitive. Value: `' + v + '`.' );
if ( !isNumber( v ) && !isnan( v ) ) {
throw new TypeError( 'invalid input argument. An input value must be a number primitive. Value: `' + v + '`.' );
}

@@ -30,0 +31,0 @@ if ( idx < 0 ) {

@@ -67,7 +67,7 @@ 'use strict';

if ( !isNonNegativeIntegerArray( shape ) ) {
throw new TypeError( 'matrix()::invalid input argument. A matrix shape must be an array of nonnegative integers. Value: `' + shape + '`.' );
throw new TypeError( 'invalid input argument. A matrix shape must be an array of nonnegative integers. Value: `' + shape + '`.' );
}
ndims = shape.length;
if ( ndims !== 2 ) {
throw new Error( 'matrix()::invalid input argument. Shape must be a 2-element array. Value: `' + shape + '`.' );
throw new Error( 'invalid input argument. Shape must be a 2-element array. Value: `' + shape + '`.' );
}

@@ -77,3 +77,3 @@ // If a `dtype` has been provided, validate...

if ( !contains( DTYPES, dtype ) ) {
throw new TypeError( 'matrix()::invalid input argument. Unrecognized/unsupported data type. Value: `' + dtype + '`.' );
throw new TypeError( 'invalid input argument. Unrecognized/unsupported data type. Value: `' + dtype + '`.' );
}

@@ -91,6 +91,6 @@ } else {

if ( !contains( DTYPES, dt ) && !isArray( data ) ) {
throw new TypeError( 'matrix()::invalid input argument. Input data must be a valid type. Consult the documentation for a list of valid data types. Value: `' + data + '`.' );
throw new TypeError( 'invalid input argument. Input data must be a valid type. Consult the documentation for a list of valid data types. Value: `' + data + '`.' );
}
if ( len !== data.length ) {
throw new Error( 'matrix()::invalid input argument. Matrix shape does not match the input data length.' );
throw new Error( 'invalid input argument. Matrix shape does not match the input data length.' );
}

@@ -97,0 +97,0 @@ // Only cast if either 1) both a `data` and `dtype` argument have been provided and they do not agree or 2) when provided a plain Array...

@@ -56,3 +56,3 @@ 'use strict';

if ( ndims !== 2 ) {
throw new Error( 'matrix()::invalid input argument. Shape must be a 2-element array. Value: `' + shape + '`.' );
throw new Error( 'invalid input argument. Shape must be a 2-element array. Value: `' + shape + '`.' );
}

@@ -67,7 +67,7 @@ len = 1;

if ( !contains( DTYPES, dtype ) ) {
throw new TypeError( 'matrix()::invalid input argument. Input data must be a valid type. Consult the documentation for a list of valid data types. Value: `' + data + '`.' );
throw new TypeError( 'invalid input argument. Input data must be a valid type. Consult the documentation for a list of valid data types. Value: `' + data + '`.' );
}
}
if ( len !== data.length ) {
throw new Error( 'matrix()::invalid input argument. Matrix shape does not match the input data length.' );
throw new Error( 'invalid input argument. Matrix shape does not match the input data length.' );
}

@@ -74,0 +74,0 @@ } else {

@@ -41,3 +41,3 @@ 'use strict';

if ( !isNonNegativeIntegerArray( rows ) ) {
throw new TypeError( 'mget()::invalid input argument. Linear indices must be specified as a nonnegative integer array. Value: `' + rows + '`.' );
throw new TypeError( 'invalid input argument. Linear indices must be specified as a nonnegative integer array. Value: `' + rows + '`.' );
}

@@ -80,3 +80,3 @@ // Filter the input indices to ensure within bounds...

else {
throw new TypeError( 'mget()::invalid input argument. Row indices must be specified as a nonnegative integer array. Value: `' + rows + '`.' );
throw new TypeError( 'invalid input argument. Row indices must be specified as a nonnegative integer array. Value: `' + rows + '`.' );
}

@@ -100,3 +100,3 @@

else {
throw new TypeError( 'mget()::invalid input argument. Column indices must be specified as a nonnegative integer array. Value: `' + cols + '`.' );
throw new TypeError( 'invalid input argument. Column indices must be specified as a nonnegative integer array. Value: `' + cols + '`.' );
}

@@ -103,0 +103,0 @@ nRows = i.length;

@@ -6,2 +6,3 @@ 'use strict';

var isFunction = require( 'validate.io-function' ),
isnan = require( 'validate.io-nan' ),
isNumber = require( 'validate.io-number-primitive' ),

@@ -47,3 +48,3 @@ isNonNegativeIntegerArray = require( 'validate.io-nonnegative-integer-array' );

else {
throw new TypeError( 'mset()::invalid input argument. Row and column indices must be arrays of nonnegative integers. Value: `' + idx + '`.' );
throw new TypeError( 'invalid input argument. Row and column indices must be arrays of nonnegative integers. Value: `' + idx + '`.' );
}

@@ -81,3 +82,3 @@ return out;

if ( !isNonNegativeIntegerArray( args[ 0 ] ) ) {
throw new TypeError( 'mset()::invalid input argument. First argument must be an array of nonnegative integers. Value: `' + args[ 0 ] + '`.' );
throw new TypeError( 'invalid input argument. First argument must be an array of nonnegative integers. Value: `' + args[ 0 ] + '`.' );
}

@@ -89,3 +90,3 @@ // indices, clbk

// indices, number
else if ( isNumber( args[ 1 ] ) ) {
else if ( isNumber( args[ 1 ] ) || isnan( args[ 1 ] ) ) {
mset1( this, args[ 0 ], args[ 1 ] );

@@ -104,3 +105,3 @@ }

if ( !isNonNegativeIntegerArray( args[ 0 ] ) ) {
throw new TypeError( 'mset()::invalid input argument. First argument must be an array of nonnegative integers. Value: `' + args[ 0 ] + '`.' );
throw new TypeError( 'invalid input argument. First argument must be an array of nonnegative integers. Value: `' + args[ 0 ] + '`.' );
}

@@ -134,3 +135,3 @@ mset2( this, args[ 0 ], args[ 1 ], args[ 2 ] );

if ( !isFunction( args[ 2 ] ) ) {
throw new TypeError( 'mset()::invalid input argument. Callback argument must be a function. Value: `' + args[ 2 ] + '`.' );
throw new TypeError( 'invalid input argument. Callback argument must be a function. Value: `' + args[ 2 ] + '`.' );
}

@@ -137,0 +138,0 @@ rows = getIndices( args[ 0 ], this.shape[ 0 ] );

@@ -26,3 +26,3 @@ 'use strict';

if ( m.length !== len ) {
throw new Error( 'mset()::invalid input argument. Number of indices does not match the number of elements in the value matrix.' );
throw new Error( 'invalid input argument. Number of indices does not match the number of elements in the value matrix.' );
}

@@ -29,0 +29,0 @@ sgn0 = ( s0 < 0 ) ? -1 : 1;

@@ -26,3 +26,3 @@ 'use strict';

if ( m.shape[ 0 ] !== nRows || m.shape[ 1 ] !== nCols ) {
throw new Error( 'mset()::invalid input argument. The dimensions given by the row and column indices do not match the value matrix dimensions.' );
throw new Error( 'invalid input argument. The dimensions given by the row and column indices do not match the value matrix dimensions.' );
}

@@ -29,0 +29,0 @@ for ( i = 0; i < nRows; i++ ) {

@@ -6,2 +6,3 @@ 'use strict';

var isNonNegativeInteger = require( 'validate.io-nonnegative-integer' ),
isnan = require( 'validate.io-nan' ),
isNumber = require( 'validate.io-number-primitive' );

@@ -24,6 +25,6 @@

if ( !isNonNegativeInteger( i ) || !isNonNegativeInteger( j ) ) {
throw new TypeError( 'set()::invalid input argument. Row and column indices must be nonnegative integers. Values: `[' + i + ',' + j + ']`.' );
throw new TypeError( 'invalid input argument. Row and column indices must be nonnegative integers. Values: `[' + i + ',' + j + ']`.' );
}
if ( !isNumber( v ) ) {
throw new TypeError( 'set()::invalid input argument. An input value must be a number primitive. Value: `' + v + '`.' );
if ( !isNumber( v ) && !isnan( v ) ) {
throw new TypeError( 'invalid input argument. An input value must be a number primitive. Value: `' + v + '`.' );
}

@@ -30,0 +31,0 @@ i = this.offset + i*this.strides[0] + j*this.strides[1];

@@ -39,7 +39,7 @@ 'use strict';

if ( !isString( seq ) ) {
throw new TypeError( 'sget()::invalid input argument. Must provide a string primitive. Value: `' + seq + '`.' );
throw new TypeError( 'invalid input argument. Must provide a string primitive. Value: `' + seq + '`.' );
}
seqs = seq.split( ',' );
if ( seqs.length !== 2 ) {
throw new Error( 'sget()::invalid input argument. Subsequence string must specify row and column subsequences. Value: `' + seq + '`.' );
throw new Error( 'invalid input argument. Subsequence string must specify row and column subsequences. Value: `' + seq + '`.' );
}

@@ -46,0 +46,0 @@ rows = ispace( seqs[ 0 ], this.shape[ 0 ] );

@@ -38,7 +38,7 @@ 'use strict';

if ( !isString( seq ) ) {
throw new TypeError( 'sset()::invalid input argument. Must provide a string primitive. Value: `' + seq + '`.' );
throw new TypeError( 'invalid input argument. Must provide a string primitive. Value: `' + seq + '`.' );
}
seqs = seq.split( ',' );
if ( seqs.length !== 2 ) {
throw new Error( 'sset()::invalid input argument. Subsequence string must specify row and column subsequences. Value: `' + seq + '`.' );
throw new Error( 'invalid input argument. Subsequence string must specify row and column subsequences. Value: `' + seq + '`.' );
}

@@ -82,6 +82,6 @@ if ( isFunction( val ) ) {

if ( nRows !== mat.shape[ 0 ] ) {
throw new Error( 'sset()::invalid input arguments. Row subsequence does not match input matrix dimensions. Expected a [' + nRows + ',' + nCols + '] matrix and instead received a [' + mat.shape.join( ',' ) + '] matrix.' );
throw new Error( 'invalid input arguments. Row subsequence does not match input matrix dimensions. Expected a [' + nRows + ',' + nCols + '] matrix and instead received a [' + mat.shape.join( ',' ) + '] matrix.' );
}
if ( nCols !== mat.shape[ 1 ] ) {
throw new Error( 'sset()::invalid input arguments. Column subsequence does not match input matrix dimensions. Expected a [' + nRows + ',' + nCols + '] matrix and instead received a [' + mat.shape.join( ',' ) + '] matrix.' );
throw new Error( 'invalid input arguments. Column subsequence does not match input matrix dimensions. Expected a [' + nRows + ',' + nCols + '] matrix and instead received a [' + mat.shape.join( ',' ) + '] matrix.' );
}

@@ -88,0 +88,0 @@ s2 = mat.strides[ 0 ];

@@ -72,6 +72,6 @@ 'use strict';

if ( nRows !== mat.shape[ 0 ] ) {
throw new Error( 'sset()::invalid input arguments. Row subsequence does not match input matrix dimensions. Expected a [' + nRows + ',' + nCols + '] matrix and instead received a [' + mat.shape.join( ',' ) + '] matrix.' );
throw new Error( 'invalid input arguments. Row subsequence does not match input matrix dimensions. Expected a [' + nRows + ',' + nCols + '] matrix and instead received a [' + mat.shape.join( ',' ) + '] matrix.' );
}
if ( nCols !== mat.shape[ 1 ] ) {
throw new Error( 'sset()::invalid input arguments. Column subsequence does not match input matrix dimensions. Expected a [' + nRows + ',' + nCols + '] matrix and instead received a [' + mat.shape.join( ',' ) + '] matrix.' );
throw new Error( 'invalid input arguments. Column subsequence does not match input matrix dimensions. Expected a [' + nRows + ',' + nCols + '] matrix and instead received a [' + mat.shape.join( ',' ) + '] matrix.' );
}

@@ -78,0 +78,0 @@ s2 = mat.strides[ 0 ];

{
"name": "dstructs-matrix",
"version": "2.0.0",
"version": "2.0.1",
"description": "Matrices.",

@@ -13,8 +13,12 @@ "author": {

"email": "kgryte@gmail.com"
},
{
"name": "Philipp Burckhardt",
"email": "pburckhardt@outlook.com"
}
],
"scripts": {
"test": "./node_modules/.bin/mocha",
"test-cov": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec",
"coveralls": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coveralls/coverage --report lcovonly -- -R spec && cat ./reports/coveralls/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./reports/coveralls"
"test": "mocha",
"test-cov": "istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec",
"codecov": "istanbul cover ./node_modules/.bin/_mocha --dir ./reports/codecov/coverage --report lcovonly -- -R spec && cat ./reports/codecov/coverage/lcov.info | codecov && rm -rf ./reports/codecov"
},

@@ -56,2 +60,3 @@ "main": "./lib",

"validate.io-integer-primitive": "^1.0.0",
"validate.io-nan": "^1.0.3",
"validate.io-nonnegative-integer": "^1.0.0",

@@ -63,11 +68,12 @@ "validate.io-nonnegative-integer-array": "^1.0.1",

"devDependencies": {
"chai": "2.x.x",
"coveralls": "^2.11.1",
"chai": "3.x.x",
"codecov": "^1.0.1",
"istanbul": "^0.3.0",
"jshint": "2.x.x",
"jshint-stylish": "^1.0.0",
"jshint-stylish": "2.x.x",
"mocha": "2.x.x",
"type-name": "^1.0.1"
"type-name": "^1.0.1",
"validate.io-typed-array": "^1.0.0"
},
"license": "MIT"
}
Matrix
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url]
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]

@@ -252,3 +252,3 @@ > Matrices.

Sets a `Matrix` element located at a specified [`index`](#linear-indexing). If `index < 0`, the index refers to a position relative to the `Matrix` length, where `index = -1` corresponds to the last element.
Sets a `Matrix` element located at a specified [`index`](#linear-indexing). If `index < 0`, the index refers to a position relative to the `Matrix` length, where `index = -1` corresponds to the last element.

@@ -413,3 +413,3 @@ ``` javascript

and is __expected__ to return a `number` primitive or a value which can be cast to a `number` primitive.
and is __expected__ to return a `number` primitive or a value which can be cast to a `number` primitive.

@@ -486,3 +486,3 @@ ``` javascript

Returns a `Matrix` element located at a specified [`index`](#linear-indexing). If `index < 0`, the index refers to a position relative to the `Matrix` length, where `index = -1` corresponds to the last element.
Returns a `Matrix` element located at a specified [`index`](#linear-indexing). If `index < 0`, the index refers to a position relative to the `Matrix` length, where `index = -1` corresponds to the last element.

@@ -575,3 +575,3 @@ ``` javascript

2 3
4 5
4 5
6 7

@@ -650,3 +650,3 @@ 8 9 ]

rows[ i ][ j ] = parseFloat( cols[ j ] );
}
}
}

@@ -732,3 +732,3 @@ ```

* `Matrix` properties and methods are the same as for the higher-level API, with the exception that `Matrix` properties are __no__ longer read-only and methods do __not__ perform input argument validation.
* Setting properties is __not__ recommended as the `Matrix` can become corrupted; e.g., incompatible dimensions, out-of-bounds indexing, etc. In contrast to the strict API above, setting `Matrix` properties will __not__ result in an `error` being thrown. Accordingly, property modification may introduce silent bugs.
* Setting properties is __not__ recommended as the `Matrix` can become corrupted; e.g., incompatible dimensions, out-of-bounds indexing, etc. In contrast to the strict API above, setting `Matrix` properties will __not__ result in an `error` being thrown. Accordingly, property modification may introduce silent bugs.
* The lower-level `Matrix` constructor has the same interface as the higher-level `Matrix` constructor.

@@ -834,4 +834,4 @@

[coveralls-image]: https://img.shields.io/coveralls/dstructs/matrix/master.svg
[coveralls-url]: https://coveralls.io/r/dstructs/matrix?branch=master
[codecov-image]: https://img.shields.io/c/github/codecov/dstructs/matrix/master.svg
[codecov-url]: https://codecov.io/github/dstructs/matrix?branch=master

@@ -838,0 +838,0 @@ [dependencies-image]: http://img.shields.io/david/dstructs/matrix.svg

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