Skip to content

Commit d0354fe

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents c27328f + 9495f38 commit d0354fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+17275
-5
lines changed

lib/node_modules/@stdlib/namespace/lib/namespace/r.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,36 @@ ns.push({
568568
]
569569
});
570570

571+
ns.push({
572+
'alias': 'random.streams.laplace',
573+
'path': '@stdlib/random/streams/laplace',
574+
'value': require( '@stdlib/random/streams/laplace' ),
575+
'type': 'Function',
576+
'related': [
577+
'@stdlib/random/iter/laplace'
578+
]
579+
});
580+
581+
ns.push({
582+
'alias': 'random.streams.levy',
583+
'path': '@stdlib/random/streams/levy',
584+
'value': require( '@stdlib/random/streams/levy' ),
585+
'type': 'Function',
586+
'related': [
587+
'@stdlib/random/iter/levy'
588+
]
589+
});
590+
591+
ns.push({
592+
'alias': 'random.streams.logistic',
593+
'path': '@stdlib/random/streams/logistic',
594+
'value': require( '@stdlib/random/streams/logistic' ),
595+
'type': 'Function',
596+
'related': [
597+
'@stdlib/random/iter/logistic'
598+
]
599+
});
600+
571601
ns.push({
572602
'alias': 'random.streams.minstd',
573603
'path': '@stdlib/random/streams/minstd',

lib/node_modules/@stdlib/random/streams/cauchy/lib/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
var Readable = require( 'readable-stream' ).Readable;
2424
var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive;
25+
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2527
var isError = require( '@stdlib/assert/is-error' );
2628
var copy = require( '@stdlib/utils/copy' );
2729
var inherit = require( '@stdlib/utils/inherit' );
@@ -201,6 +203,7 @@ function destroy( error ) {
201203
* @param {PRNGStateMT19937} [options.state] - pseudorandom number generator state
202204
* @param {boolean} [options.copy=true] - boolean indicating whether to copy a provided pseudorandom number generator state
203205
* @param {PositiveInteger} [options.siter] - number of iterations after which to emit the PRNG state
206+
* @throws {TypeError} `x0` must be a number
204207
* @throws {TypeError} `gamma` must be a positive number
205208
* @throws {TypeError} options argument must be an object
206209
* @throws {TypeError} must provide valid options
@@ -231,6 +234,9 @@ function RandomStream( x0, gamma, options ) {
231234
}
232235
return new RandomStream( x0, gamma );
233236
}
237+
if ( !isNumber( x0 ) || isnan( x0 ) ) {
238+
throw new TypeError( 'invalid argument. First argument must be a number primitive and not `NaN`. Value: `'+x0+'`.' );
239+
}
234240
if ( !isPositiveNumber( gamma ) ) {
235241
throw new TypeError( 'invalid argument. Second argument must be a positive number. Value: `'+gamma+'`.' );
236242
}

lib/node_modules/@stdlib/random/streams/cauchy/test/test.factory.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,64 @@ tape( 'the function returns a factory function (parameters + options)', function
5959
t.end();
6060
});
6161

62+
tape( 'the function returns a function which throws an error if location parameter `x0` is not a number primitive', function test( t ) {
63+
var values;
64+
var i;
65+
66+
values = [
67+
'5',
68+
null,
69+
true,
70+
false,
71+
void 0,
72+
NaN,
73+
[],
74+
{},
75+
function noop() {}
76+
];
77+
78+
for ( i = 0; i < values.length; i++ ) {
79+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
80+
}
81+
t.end();
82+
83+
function badValue( value ) {
84+
return function badValue() {
85+
var createStream = factory();
86+
createStream( value, 1.0 );
87+
};
88+
}
89+
});
90+
91+
tape( 'the function returns a function which throws an error if location parameter `x0` is not a number primitive (parameters)', function test( t ) {
92+
var values;
93+
var i;
94+
95+
values = [
96+
'5',
97+
null,
98+
true,
99+
false,
100+
void 0,
101+
NaN,
102+
[],
103+
{},
104+
function noop() {}
105+
];
106+
107+
for ( i = 0; i < values.length; i++ ) {
108+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
109+
}
110+
t.end();
111+
112+
function badValue( value ) {
113+
return function badValue() {
114+
var createStream = factory( value, 1.0 );
115+
createStream();
116+
};
117+
}
118+
});
119+
62120
tape( 'the function returns a function which throws an error if scale parameter `gamma` is not a positive number primitive', function test( t ) {
63121
var values;
64122
var i;

lib/node_modules/@stdlib/random/streams/cauchy/test/test.main.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,34 @@ tape( 'main export is a function', function test( t ) {
4242
t.end();
4343
});
4444

45+
tape( 'the function throws an error if location parameter `x0` is not a number primitive', function test( t ) {
46+
var values;
47+
var i;
48+
49+
values = [
50+
'5',
51+
null,
52+
true,
53+
false,
54+
void 0,
55+
NaN,
56+
[],
57+
{},
58+
function noop() {}
59+
];
60+
61+
for ( i = 0; i < values.length; i++ ) {
62+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
63+
}
64+
t.end();
65+
66+
function badValue( value ) {
67+
return function badValue() {
68+
randomStream( value, 1.0 );
69+
};
70+
}
71+
});
72+
4573
tape( 'the function throws an error if scale parameter `gamma` is not a positive number primitive', function test( t ) {
4674
var values;
4775
var i;

lib/node_modules/@stdlib/random/streams/cauchy/test/test.object_mode.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,34 @@ tape( 'main export is a function', function test( t ) {
3636
t.end();
3737
});
3838

39+
tape( 'the function throws an error if location parameter `x0` is not a number primitive', function test( t ) {
40+
var values;
41+
var i;
42+
43+
values = [
44+
'5',
45+
null,
46+
true,
47+
false,
48+
void 0,
49+
NaN,
50+
[],
51+
{},
52+
function noop() {}
53+
];
54+
55+
for ( i = 0; i < values.length; i++ ) {
56+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
57+
}
58+
t.end();
59+
60+
function badValue( value ) {
61+
return function badValue() {
62+
objectMode( value, 1.0 );
63+
};
64+
}
65+
});
66+
3967
tape( 'the function throws an error if scale parameter `gamma` is not a positive number primitive', function test( t ) {
4068
var values;
4169
var i;

lib/node_modules/@stdlib/random/streams/cosine/lib/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
var Readable = require( 'readable-stream' ).Readable;
2424
var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive;
25+
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2527
var isError = require( '@stdlib/assert/is-error' );
2628
var copy = require( '@stdlib/utils/copy' );
2729
var inherit = require( '@stdlib/utils/inherit' );
@@ -201,6 +203,7 @@ function destroy( error ) {
201203
* @param {PRNGStateMT19937} [options.state] - pseudorandom number generator state
202204
* @param {boolean} [options.copy=true] - boolean indicating whether to copy a provided pseudorandom number generator state
203205
* @param {PositiveInteger} [options.siter] - number of iterations after which to emit the PRNG state
206+
* @throws {TypeError} `mu` must be a number
204207
* @throws {TypeError} `s` must be a positive number
205208
* @throws {TypeError} options argument must be an object
206209
* @throws {TypeError} must provide valid options
@@ -231,6 +234,9 @@ function RandomStream( mu, s, options ) {
231234
}
232235
return new RandomStream( mu, s );
233236
}
237+
if ( !isNumber( mu ) || isnan( mu ) ) {
238+
throw new TypeError( 'invalid argument. First argument must be a number primitive and not `NaN`. Value: `'+mu+'`.' );
239+
}
234240
if ( !isPositiveNumber( s ) ) {
235241
throw new TypeError( 'invalid argument. Second argument must be a positive number. Value: `'+s+'`.' );
236242
}

lib/node_modules/@stdlib/random/streams/cosine/test/test.factory.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,64 @@ tape( 'the function returns a factory function (parameters + options)', function
5959
t.end();
6060
});
6161

62+
tape( 'the function returns a function which throws an error if location parameter `mu` is not a number primitive', function test( t ) {
63+
var values;
64+
var i;
65+
66+
values = [
67+
'5',
68+
null,
69+
true,
70+
false,
71+
void 0,
72+
NaN,
73+
[],
74+
{},
75+
function noop() {}
76+
];
77+
78+
for ( i = 0; i < values.length; i++ ) {
79+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
80+
}
81+
t.end();
82+
83+
function badValue( value ) {
84+
return function badValue() {
85+
var createStream = factory();
86+
createStream( value, 1.0 );
87+
};
88+
}
89+
});
90+
91+
tape( 'the function returns a function which throws an error if location parameter `mu` is not a number primitive (parameters)', function test( t ) {
92+
var values;
93+
var i;
94+
95+
values = [
96+
'5',
97+
null,
98+
true,
99+
false,
100+
void 0,
101+
NaN,
102+
[],
103+
{},
104+
function noop() {}
105+
];
106+
107+
for ( i = 0; i < values.length; i++ ) {
108+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
109+
}
110+
t.end();
111+
112+
function badValue( value ) {
113+
return function badValue() {
114+
var createStream = factory( value, 2.0 );
115+
createStream();
116+
};
117+
}
118+
});
119+
62120
tape( 'the function returns a function which throws an error if scale parameter `s` is not a positive number primitive', function test( t ) {
63121
var values;
64122
var i;

lib/node_modules/@stdlib/random/streams/cosine/test/test.main.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,34 @@ tape( 'main export is a function', function test( t ) {
4242
t.end();
4343
});
4444

45+
tape( 'the function throws an error if location parameter `mu` is not a number primitive', function test( t ) {
46+
var values;
47+
var i;
48+
49+
values = [
50+
'5',
51+
null,
52+
true,
53+
false,
54+
void 0,
55+
NaN,
56+
[],
57+
{},
58+
function noop() {}
59+
];
60+
61+
for ( i = 0; i < values.length; i++ ) {
62+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
63+
}
64+
t.end();
65+
66+
function badValue( value ) {
67+
return function badValue() {
68+
randomStream( value, 1.0 );
69+
};
70+
}
71+
});
72+
4573
tape( 'the function throws an error if scale parameter `s` is not a positive number primitive', function test( t ) {
4674
var values;
4775
var i;

lib/node_modules/@stdlib/random/streams/cosine/test/test.object_mode.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,34 @@ tape( 'main export is a function', function test( t ) {
3636
t.end();
3737
});
3838

39+
tape( 'the function throws an error if location parameter `mu` is not a number primitive', function test( t ) {
40+
var values;
41+
var i;
42+
43+
values = [
44+
'5',
45+
null,
46+
true,
47+
false,
48+
void 0,
49+
NaN,
50+
[],
51+
{},
52+
function noop() {}
53+
];
54+
55+
for ( i = 0; i < values.length; i++ ) {
56+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
57+
}
58+
t.end();
59+
60+
function badValue( value ) {
61+
return function badValue() {
62+
objectMode( 0.0, value );
63+
};
64+
}
65+
});
66+
3967
tape( 'the function throws an error if scale parameter `s` is not a positive number primitive', function test( t ) {
4068
var values;
4169
var i;

0 commit comments

Comments
 (0)