Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Nov 1, 2023
1 parent 05a53c2 commit 6a2c4c3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 300 deletions.
1 change: 1 addition & 0 deletions .github/.keepalive
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-11-01T04:39:26.119Z
12 changes: 10 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ jobs:
fi
# Trim leading and trailing whitespace:
dep=$(echo "$dep" | xargs)
version="^$(npm view $dep version)"
version="$(npm view $dep version)"
if [[ -z "$version" ]]; then
continue
fi
version="^$version"
jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp
mv package.json.tmp package.json
done
Expand All @@ -192,7 +196,11 @@ jobs:
fi
# Trim leading and trailing whitespace:
dep=$(echo "$dep" | xargs)
version="^$(npm view $dep version)"
version="$(npm view $dep version)"
if [[ -z "$version" ]]; then
continue
fi
version="^$version"
jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp
mv package.json.tmp package.json
done
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Stephannie Jiménez Gacha <[email protected]>
Yernar Yergaziyev <[email protected]>
orimiles5 <[email protected]>
rei2hu <[email protected]>
Robert Gislason <[email protected]>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@stdlib/assert-is-number": "^0.1.1",
"@stdlib/assert-is-positive-number": "^0.1.1",
"@stdlib/stats-base-dists-cauchy-cdf": "^0.1.0",
"@stdlib/stats-base-dists-cauchy-entropy": "^0.1.0",
"@stdlib/stats-base-dists-cauchy-entropy": "^0.1.1",
"@stdlib/stats-base-dists-cauchy-logcdf": "^0.1.0",
"@stdlib/stats-base-dists-cauchy-logpdf": "^0.1.0",
"@stdlib/stats-base-dists-cauchy-median": "^0.1.1",
Expand Down
301 changes: 4 additions & 297 deletions test/dist/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2023 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.
Expand All @@ -21,306 +21,13 @@
// MODULES //

var tape = require( 'tape' );
var isFunction = require( '@stdlib/assert-is-function' );
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
var quantile = require( '@stdlib/stats-base-dists-cauchy-quantile' );
var logcdf = require( '@stdlib/stats-base-dists-cauchy-logcdf' );
var logpdf = require( '@stdlib/stats-base-dists-cauchy-logpdf' );
var cdf = require( '@stdlib/stats-base-dists-cauchy-cdf' );
var pdf = require( '@stdlib/stats-base-dists-cauchy-pdf' );
var entropy = require( '@stdlib/stats-base-dists-cauchy-entropy' );
var median = require( '@stdlib/stats-base-dists-cauchy-median' );
var mode = require( '@stdlib/stats-base-dists-cauchy-mode' );
var Cauchy = require( './../../dist' );
var main = require( './../../dist' );


// TESTS //

tape( 'main export is a function', function test( t ) {
tape( 'main export is defined', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof Cauchy, 'function', 'main export is a function' );
t.end();
});

tape( 'the function throws an error if provided a `x0` argument which is not a number primitive', function test( t ) {
var values;
var i;

values = [
'5',
NaN,
true,
false,
void 0,
null,
{},
[],
function noop() {}
];

for ( i = 0; i < values.length; i++ ) {
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
}
t.end();

function badValue( value ) {
return function badValue() {
// eslint-disable-next-line no-new
new Cauchy( value, 1.0 );
};
}
});

tape( 'the function throws an error if provided a `gamma` argument which is not a positive number', function test( t ) {
var values;
var i;

values = [
'5',
-5.0,
0.0,
NaN,
true,
false,
void 0,
null,
{},
[],
function noop() {}
];

for ( i = 0; i < values.length; i++ ) {
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
}
t.end();

function badValue( value ) {
return function badValue() {
// eslint-disable-next-line no-new
new Cauchy( 2.0, value );
};
}
});

tape( 'if provided arguments, the function requires both `x0` and `gamma`', function test( t ) {
t.throws( foo, TypeError, 'throws an error' );
t.end();

function foo() {
// eslint-disable-next-line no-new
new Cauchy( 2.0 );
}
});

tape( 'the function returns a new distribution instance (default parameters)', function test( t ) {
var cauchy = new Cauchy();
t.strictEqual( cauchy instanceof Cauchy, true, 'returns an instance' );
t.end();
});

tape( 'the function returns a new distribution instance (custom parameters)', function test( t ) {
var cauchy = new Cauchy( 2.0, 4.0 );
t.strictEqual( cauchy instanceof Cauchy, true, 'returns an instance' );
t.end();
});

tape( 'the function can be invoked without the new operator', function test( t ) {
// eslint-disable-next-line new-cap
var cauchy = Cauchy();
t.strictEqual( cauchy instanceof Cauchy, true, 'returns an instance' );

// eslint-disable-next-line new-cap
cauchy = Cauchy( 2.0, 4.0 );
t.strictEqual( cauchy instanceof Cauchy, true, 'returns an instance' );

t.end();
});

tape( 'the created distribution has a property for getting and setting `x0`', function test( t ) {
var cauchy;

cauchy = new Cauchy( 2.0, 4.0 );
t.strictEqual( hasOwnProp( cauchy, 'x0' ), true, 'has property' );
t.strictEqual( cauchy.x0, 2.0, 'returns expected value' );

cauchy.x0 = 3.0;
t.strictEqual( cauchy.x0, 3.0, 'returns expected value' );

t.end();
});

tape( 'the created distribution throws an error if one attempts to set `x0` to a value which is not a number primitive', function test( t ) {
var values;
var i;

values = [
'5',
NaN,
true,
false,
void 0,
null,
{},
[],
function noop() {}
];

for ( i = 0; i < values.length; i++ ) {
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
}
t.end();

function badValue( value ) {
return function badValue() {
var cauchy = new Cauchy();
cauchy.x0 = value;
};
}
});

tape( 'the created distribution has a property for getting and setting `gamma`', function test( t ) {
var cauchy;

cauchy = new Cauchy( 2.0, 4.0 );
t.strictEqual( hasOwnProp( cauchy, 'gamma' ), true, 'has property' );
t.strictEqual( cauchy.gamma, 4.0, 'returns expected value' );

cauchy.gamma = 3.0;
t.strictEqual( cauchy.gamma, 3.0, 'returns expected value' );

t.end();
});

tape( 'the created distribution throws an error if one attempts to set `gamma` to a value which is not a positive number', function test( t ) {
var values;
var i;

values = [
'5',
-5.0,
0.0,
NaN,
true,
false,
void 0,
null,
{},
[],
function noop() {}
];

for ( i = 0; i < values.length; i++ ) {
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
}
t.end();

function badValue( value ) {
return function badValue() {
var cauchy = new Cauchy();
cauchy.gamma = value;
};
}
});

tape( 'the distribution prototype has a property for retrieving the distribution entropy', function test( t ) {
var cauchy;

t.strictEqual( hasOwnProp( Cauchy.prototype, 'entropy' ), true, 'has property' );

cauchy = new Cauchy();
t.strictEqual( cauchy.entropy, entropy( 1.0, 1.0 ), 'returns expected value' );

t.end();
});

tape( 'the distribution prototype has a property for retrieving the distribution median', function test( t ) {
var cauchy;

t.strictEqual( hasOwnProp( Cauchy.prototype, 'median' ), true, 'has property' );

cauchy = new Cauchy( 5.0, 2.0 );
t.strictEqual( cauchy.median, median( 5.0, 2.0 ), 'returns expected value' );

t.end();
});

tape( 'the distribution prototype has a property for retrieving the distribution mode', function test( t ) {
var cauchy;

t.strictEqual( hasOwnProp( Cauchy.prototype, 'mode' ), true, 'has property' );

cauchy = new Cauchy( 2.0, 3.0 );
t.strictEqual( cauchy.mode, mode( 2.0, 3.0 ), 'returns expected value' );

t.end();
});

tape( 'the distribution prototype has a method for evaluating the cumulative distribution function (CDF)', function test( t ) {
var cauchy;
var y;

t.strictEqual( hasOwnProp( Cauchy.prototype, 'cdf' ), true, 'has property' );
t.strictEqual( isFunction( Cauchy.prototype.cdf ), true, 'has method' );

cauchy = new Cauchy();
y = cauchy.cdf( 0.5 );

t.strictEqual( y, cdf( 0.5, 0.0, 1.0 ), 'returns expected value' );
t.end();
});

tape( 'the distribution prototype has a method for evaluating the natural logarithm of the cumulative distribution function (logCDF)', function test( t ) {
var cauchy;
var y;

t.strictEqual( hasOwnProp( Cauchy.prototype, 'logcdf' ), true, 'has property' );
t.strictEqual( isFunction( Cauchy.prototype.logcdf ), true, 'has method' );

cauchy = new Cauchy();
y = cauchy.logcdf( 0.5 );

t.strictEqual( y, logcdf( 0.5, 0.0, 1.0 ), 'returns expected value' );
t.end();
});

tape( 'the distribution prototype has a method for evaluating the natural logarithm of the probability density function (logPDF)', function test( t ) {
var cauchy;
var y;

t.strictEqual( hasOwnProp( Cauchy.prototype, 'logpdf' ), true, 'has property' );
t.strictEqual( isFunction( Cauchy.prototype.logpdf ), true, 'has method' );

cauchy = new Cauchy();
y = cauchy.logpdf( 0.5 );

t.strictEqual( y, logpdf( 0.5, 0.0, 1.0 ), 'returns expected value' );
t.end();
});

tape( 'the distribution prototype has a method for evaluating the probability density function (PDF)', function test( t ) {
var cauchy;
var y;

t.strictEqual( hasOwnProp( Cauchy.prototype, 'pdf' ), true, 'has property' );
t.strictEqual( isFunction( Cauchy.prototype.pdf ), true, 'has method' );

cauchy = new Cauchy();
y = cauchy.pdf( 0.2 );

t.strictEqual( y, pdf( 0.2, 0.0, 1.0 ), 'returns expected value' );
t.end();
});

tape( 'the distribution prototype has a method for evaluating the quantile function', function test( t ) {
var cauchy;
var y;

t.strictEqual( hasOwnProp( Cauchy.prototype, 'quantile' ), true, 'has property' );
t.strictEqual( isFunction( Cauchy.prototype.quantile ), true, 'has method' );

cauchy = new Cauchy();
y = cauchy.quantile( 0.8 );

t.strictEqual( y, quantile( 0.8, 0.0, 1.0 ), 'returns expected value' );
t.strictEqual( main !== void 0, true, 'main export is defined' );
t.end();
});

0 comments on commit 6a2c4c3

Please sign in to comment.