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 223ce5f commit 8bba307
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 269 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:19:57.605Z
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 <steff456@hotmail.com>
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
orimiles5 <97595296+orimiles5@users.noreply.github.com>
rei2hu <reimu@reimu.ws>
Robert Gislason <gztown2216@yahoo.com>
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
"dependencies": {
"@stdlib/assert-is-probability": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-cdf": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-entropy": "^0.1.0",
"@stdlib/stats-base-dists-bernoulli-entropy": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-kurtosis": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-mean": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-median": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-mgf": "^0.1.0",
"@stdlib/stats-base-dists-bernoulli-mode": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-pmf": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-quantile": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-skewness": "^0.1.0",
"@stdlib/stats-base-dists-bernoulli-stdev": "^0.1.0",
"@stdlib/stats-base-dists-bernoulli-skewness": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-stdev": "^0.1.1",
"@stdlib/stats-base-dists-bernoulli-variance": "^0.1.1",
"@stdlib/string-format": "^0.1.1",
"@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1",
Expand All @@ -60,7 +60,7 @@
"@stdlib/assert-is-function": "^0.1.1",
"@stdlib/bench": "^0.1.0",
"@stdlib/math-base-assert-is-nan": "^0.1.1",
"@stdlib/math-base-special-ln": "^0.1.0",
"@stdlib/math-base-special-ln": "^0.1.1",
"@stdlib/math-base-special-round": "^0.1.1",
"@stdlib/random-base-randu": "^0.1.0",
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
Expand Down
267 changes: 4 additions & 263 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,272 +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-bernoulli-quantile' );
var cdf = require( '@stdlib/stats-base-dists-bernoulli-cdf' );
var mgf = require( '@stdlib/stats-base-dists-bernoulli-mgf' );
var pmf = require( '@stdlib/stats-base-dists-bernoulli-pmf' );
var entropy = require( '@stdlib/stats-base-dists-bernoulli-entropy' );
var kurtosis = require( '@stdlib/stats-base-dists-bernoulli-kurtosis' );
var skewness = require( '@stdlib/stats-base-dists-bernoulli-skewness' );
var variance = require( '@stdlib/stats-base-dists-bernoulli-variance' );
var median = require( '@stdlib/stats-base-dists-bernoulli-median' );
var mode = require( '@stdlib/stats-base-dists-bernoulli-mode' );
var stdev = require( '@stdlib/stats-base-dists-bernoulli-stdev' );
var mean = require( '@stdlib/stats-base-dists-bernoulli-mean' );
var Bernoulli = 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 Bernoulli, 'function', 'main export is a function' );
t.end();
});

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

values = [
'5',
-5.0,
-0.1,
1.2,
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 Bernoulli( value );
};
}
});

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

tape( 'the function returns a new distribution instance (custom parameters)', function test( t ) {
var bernoulli = new Bernoulli( 0.3 );
t.strictEqual( bernoulli instanceof Bernoulli, 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 bernoulli = Bernoulli();
t.strictEqual( bernoulli instanceof Bernoulli, true, 'returns an instance' );

// eslint-disable-next-line new-cap
bernoulli = Bernoulli( 0.3 );
t.strictEqual( bernoulli instanceof Bernoulli, true, 'returns an instance' );

t.end();
});

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

bernoulli = new Bernoulli( 0.4 );
t.strictEqual( hasOwnProp( bernoulli, 'p' ), true, 'has property' );
t.strictEqual( bernoulli.p, 0.4, 'returns expected value' );

bernoulli.p = 0.3;
t.strictEqual( bernoulli.p, 0.3, 'returns expected value' );

t.end();
});

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

values = [
'5',
-5.0,
-0.1,
1.2,
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 bernoulli = new Bernoulli();
bernoulli.p = value;
};
}
});

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

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

bernoulli = new Bernoulli();
t.strictEqual( bernoulli.entropy, entropy( 0.5 ), 'returns expected value' );

t.end();
});

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

t.strictEqual( hasOwnProp( Bernoulli.prototype, 'kurtosis' ), true, 'has property' );

bernoulli = new Bernoulli( 0.45 );
t.strictEqual( bernoulli.kurtosis, kurtosis( 0.45 ), 'returns expected value' );

t.end();
});

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

t.strictEqual( hasOwnProp( Bernoulli.prototype, 'mean' ), true, 'has property' );

bernoulli = new Bernoulli( 0.2 );
t.strictEqual( bernoulli.mean, mean( 0.2 ), 'returns expected value' );

t.end();
});

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

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

bernoulli = new Bernoulli( 0.3 );
t.strictEqual( bernoulli.median, median( 0.3 ), 'returns expected value' );

t.end();
});

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

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

bernoulli = new Bernoulli( 0.3 );
t.strictEqual( bernoulli.mode, mode( 0.3 ), 'returns expected value' );

t.end();
});

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

t.strictEqual( hasOwnProp( Bernoulli.prototype, 'skewness' ), true, 'has property' );

bernoulli = new Bernoulli( 0.5 );
t.strictEqual( bernoulli.skewness, skewness( 0.5 ), 'returns expected value' );

t.end();
});

tape( 'the distribution prototype has a property for retrieving the distribution standard deviation', function test( t ) {
var bernoulli;

t.strictEqual( hasOwnProp( Bernoulli.prototype, 'stdev' ), true, 'has property' );

bernoulli = new Bernoulli( 0.9 );
t.strictEqual( bernoulli.stdev, stdev( 0.9 ), 'returns expected value' );

t.end();
});

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

t.strictEqual( hasOwnProp( Bernoulli.prototype, 'variance' ), true, 'has property' );

bernoulli = new Bernoulli( 0.9 );
t.strictEqual( bernoulli.variance, variance( 0.9 ), 'returns expected value' );

t.end();
});

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

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

bernoulli = new Bernoulli();
y = bernoulli.cdf( 0.5 );

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

tape( 'the distribution prototype has a method for evaluating the moment-generating function (MGF)', function test( t ) {
var bernoulli;
var y;

t.strictEqual( hasOwnProp( Bernoulli.prototype, 'mgf' ), true, 'has property' );
t.strictEqual( isFunction( Bernoulli.prototype.mgf ), true, 'has method' );

bernoulli = new Bernoulli();
y = bernoulli.mgf( 0.5 );

t.strictEqual( y, mgf( 0.5, 0.5 ), 'returns expected value' );
t.end();
});

tape( 'the distribution prototype has a method for evaluating the probability mass function (PMF)', function test( t ) {
var bernoulli;
var y;

t.strictEqual( hasOwnProp( Bernoulli.prototype, 'pmf' ), true, 'has property' );
t.strictEqual( isFunction( Bernoulli.prototype.pmf ), true, 'has method' );

bernoulli = new Bernoulli();
y = bernoulli.pmf( 0.3 );

t.strictEqual( y, pmf( 0.3, 0.5 ), 'returns expected value' );
t.end();
});

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

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

bernoulli = new Bernoulli();
y = bernoulli.quantile( 0.8 );

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

0 comments on commit 8bba307

Please sign in to comment.