Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 77 additions & 66 deletions lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,21 @@

// MODULES //

var path = require( 'path' );
var logger = require( 'debug' );
var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
var format = require( '@stdlib/string/format' );
var copy = require( '@stdlib/utils/copy' );
var cwd = require( '@stdlib/process/cwd' );
var entryPoints = require( '@stdlib/_tools/pkgs/entry-points' ).sync;
var defaults = require( './defaults.json' );
var validate = require( './validate.js' );
var resolveDeps = require( './resolve.sync.js' );
var resolveDevDeps = require( './resolve_dev.sync.js' );

var path = require('path');

Check failure on line 23 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space before the closing parenthesis in require calls

Check failure on line 23 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space after the opening parenthesis in require calls
var logger = require('debug');

Check failure on line 24 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space before the closing parenthesis in require calls

Check failure on line 24 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space after the opening parenthesis in require calls
var isStringArray = require('@stdlib/assert/is-string-array').primitives;

Check failure on line 25 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space before the closing parenthesis in require calls

Check failure on line 25 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space after the opening parenthesis in require calls
var format = require('@stdlib/string/format');

Check failure on line 26 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space before the closing parenthesis in require calls

Check failure on line 26 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space after the opening parenthesis in require calls
var copy = require('@stdlib/utils/copy');

Check failure on line 27 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space before the closing parenthesis in require calls

Check failure on line 27 in lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space after the opening parenthesis in require calls
var cwd = require('@stdlib/process/cwd');
var entryPoints = require('@stdlib/_tools/pkgs/entry-points').sync;
var defaults = require('./defaults.json');
var validate = require('./validate.js');
var resolveDeps = require('./resolve.sync.js');
var resolveDevDeps = require('./resolve_dev.sync.js');

// VARIABLES //

var debug = logger( 'pkg-deps:sync' );

var debug = logger('pkg-deps:sync');

// MAIN //

Expand All @@ -49,67 +47,80 @@
* @param {boolean} [options.builtins=false] - boolean indicating whether to include built-in packages
* @param {boolean} [options.dev=false] - boolean indicating whether to resolve dev dependencies
* @throws {TypeError} first argument must be an array of strings
* @throws {TypeError} callback argument must be a function
* @throws {TypeError} options argument must be an object
* @throws {TypeError} must provide valid options
* @returns {ObjectArray} resolved dependencies
* @returns {ObjectArray|Error} resolved dependencies or an error
*
* @example
* var pkgs = [ '/foo/bar/baz' ];
*
* var deps = pkgDeps( pkgs );
* // e.g., returns [{...}]
*/
function pkgDeps( pkgs, options ) {
var results;
var opts;
var err;
if ( !isStringArray( pkgs ) ) {
throw new TypeError( format( 'invalid argument. First argument must be an array of strings. Value: `%s`.', pkgs ) );
}
opts = copy( defaults );
if ( arguments.length > 1 ) {
err = validate( opts, options );
if ( err ) {
throw err;
}
}
debug( 'Options: %s', JSON.stringify( opts ) );
if ( opts.dir ) {
opts.dir = path.resolve( cwd(), opts.dir );
} else {
opts.dir = cwd();
}
debug( 'Base directory: %s', opts.dir );

debug( 'Resolving package entry points...' );
results = entryPoints( pkgs, opts );
if ( results instanceof Error ) {
debug( 'Encountered an error when resolving package entry points: %s', results.message );
throw results;
}
debug( 'Successfully resolved package entry points.' );

debug( 'Resolving package dependencies...' );
results = resolveDeps( results, opts.builtins );
if ( results instanceof Error ) {
debug( 'Encountered an error when resolving package dependencies: %s', results.message );
return results;
}
debug( 'Successfully resolved package dependencies.' );
if ( opts.dev === false ) {
return results;
}
debug( 'Resolving package dev dependencies...' );
results = resolveDevDeps( results, opts );
if ( results instanceof Error ) {
debug( 'Encountered an error when resolving package dev dependencies: %s', results.message );
return results;
}
debug( 'Successfully resolved package dev dependencies.' );
return results;
}
function pkgDeps(pkgs, options) {
var results;
var opts;
var err;

// Validate input: `pkgs` must be an array of strings
if (!isStringArray(pkgs)) {
throw new TypeError(format('invalid argument. First argument must be an array of strings. Value: `%s`.', pkgs));
}

// Copy default options and validate user-provided options
opts = copy(defaults);
if (arguments.length > 1) {
debug('Validating options...');
err = validate(opts, options);
if (err) {
debug('Options validation failed: %s', err.message);
throw err;
}
}

debug('Options: %s', JSON.stringify(opts));

// Resolve base directory
if (opts.dir) {
opts.dir = path.resolve(cwd(), opts.dir);
} else {
opts.dir = cwd();
}
debug('Base directory: %s', opts.dir);

// Resolve package entry points
debug('Resolving package entry points...');
results = entryPoints(pkgs, opts);
if (results instanceof Error) {
debug('Encountered an error when resolving package entry points: %s', results.message);
throw results;
}
debug('Successfully resolved package entry points.');

// Resolve main dependencies
debug('Resolving package dependencies...');
results = resolveDeps(results, opts.builtins);
if (results instanceof Error) {
debug('Encountered an error when resolving package dependencies: %s', results.message);
return results;
}
debug('Successfully resolved package dependencies.');

// If dev dependencies are not required, return results
if (opts.dev === false) {
return results;
}

// Resolve dev dependencies
debug('Resolving package dev dependencies...');
results = resolveDevDeps(results, opts);
if (results instanceof Error) {
debug('Encountered an error when resolving package dev dependencies: %s', results.message);
return results;
}
debug('Successfully resolved package dev dependencies.');

return results;
}

// EXPORTS //

Expand Down
87 changes: 44 additions & 43 deletions lib/node_modules/@stdlib/stats/base/meanpn/lib/ndarray.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

Expand All @@ -27,32 +27,33 @@ var gapxsumpw = require( '@stdlib/blas/ext/base/gapxsumpw' ).ndarray;
// MAIN //

/**
* Computes the arithmetic mean of a strided array using a two-pass error correction algorithm.
*
* ## Method
*
* - This implementation uses a two-pass approach, as suggested by Neely (1966).
*
* ## References
*
* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958).
* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036).
*
* @param {PositiveInteger} N - number of indexed elements
* @param {NumericArray} x - input array
* @param {integer} stride - stride length
* @param {NonNegativeInteger} offset - starting index
* @returns {number} arithmetic mean
*
* @example
* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
* var N = floor( x.length / 2 );
*
* var v = meanpn( N, x, 2, 1 );
* // returns 1.25
*/
* Computes the arithmetic mean of a strided array using a two-pass error correction algorithm.
*
* ## Method
*
* - This implementation uses a two-pass approach, as suggested by Neely (1966).
*
* ## References
*
* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958).
* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036).
*
* @param {PositiveInteger} N - number of indexed elements
* @param {NumericArray} x - input array
* @param {integer} stride - stride length
* @param {NonNegativeInteger} offset - starting index
* @returns {number} arithmetic mean
*
* @example
* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
* var N = floor( x.length / 2 );
*
* var v = meanpn( N, x, 2, 1 );
* // returns 1.25
*/
// cspell:ignore meanpn
function meanpn( N, x, stride, offset ) {
var mu;
var c;
Expand Down
Loading