From 1d822c29a0dfa70915ae96084d45605e3cefa889 Mon Sep 17 00:00:00 2001 From: hrshya Date: Tue, 1 Apr 2025 16:21:09 +0530 Subject: [PATCH 1/2] docs: replace manual for loop in examples --- .../math/base/special/rcbrtf/README.md | 15 +++++++------- .../base/special/rcbrtf/examples/index.js | 15 +++++++------- .../@stdlib/math/base/special/round/README.md | 14 ++++++------- .../math/base/special/round/examples/index.js | 14 ++++++------- .../math/base/special/round10/README.md | 16 +++++++-------- .../base/special/round10/examples/index.js | 16 +++++++-------- .../math/base/special/round2/README.md | 16 +++++++-------- .../base/special/round2/examples/index.js | 16 +++++++-------- .../math/base/special/roundf/README.md | 14 ++++++------- .../base/special/roundf/examples/index.js | 14 ++++++------- .../math/base/special/roundn/README.md | 20 +++++++++---------- .../base/special/roundn/examples/index.js | 20 +++++++++---------- 12 files changed, 90 insertions(+), 100 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/rcbrtf/README.md b/lib/node_modules/@stdlib/math/base/special/rcbrtf/README.md index f13e8e35e995..5f733494fa07 100644 --- a/lib/node_modules/@stdlib/math/base/special/rcbrtf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/rcbrtf/README.md @@ -86,15 +86,16 @@ v = rcbrtf( Infinity ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var rcbrtf = require( '@stdlib/math/base/special/rcbrtf' ); -var x; -var i; -for ( i = 0; i < 100; i++ ) { - x = discreteUniform( 0.0, 100.0 ); - console.log( 'rcbrtf(%d) = %d', x, rcbrtf( x ) ); -} +var opts = { + 'dtype': 'float32' +}; +var x = discreteUniform( 100, 0, 100, opts ); + +logEachMap( 'rcbrtf(%d) = %0.4f', x, rcbrtf ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/rcbrtf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/rcbrtf/examples/index.js index 3bae8de19c4f..546f86389e5c 100644 --- a/lib/node_modules/@stdlib/math/base/special/rcbrtf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/rcbrtf/examples/index.js @@ -18,12 +18,13 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var rcbrtf = require( './../lib' ); -var x; -var i; -for ( i = 0; i < 100; i++ ) { - x = discreteUniform( 0.0, 100.0 ); - console.log( 'rcbrtf(%d) = %d', x, rcbrtf( x ) ); -} +var opts = { + 'dtype': 'float32' +}; +var x = discreteUniform( 100, 0, 100, opts ); + +logEachMap( 'rcbrtf(%d) = %0.4f', x, rcbrtf ); diff --git a/lib/node_modules/@stdlib/math/base/special/round/README.md b/lib/node_modules/@stdlib/math/base/special/round/README.md index e355fc43d2cc..c6410e3b7c84 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round/README.md @@ -90,16 +90,16 @@ v = round( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var round = require( '@stdlib/math/base/special/round' ); -var x; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - console.log( 'Value: %d. Rounded: %d.', x, round( x ) ); -} +logEachMap( 'Value: %0.4f. Rounded: %0.4f.', x, round ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/round/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round/examples/index.js index 6231028fd92f..1708dccfabfc 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round/examples/index.js @@ -18,13 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var round = require( './../lib' ); -var x; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - console.log( 'Value: %d. Rounded: %d.', x, round( x ) ); -} +logEachMap( 'Value: %0.4f. Rounded: %0.4f.', x, round ); diff --git a/lib/node_modules/@stdlib/math/base/special/round10/README.md b/lib/node_modules/@stdlib/math/base/special/round10/README.md index 453f56524270..e82a6c4b5c83 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10/README.md @@ -83,18 +83,16 @@ v = round10( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var round10 = require( '@stdlib/math/base/special/round10' ); -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - v = round10( x ); - console.log( 'Value: %d. Rounded: %d.', x, v ); -} +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, round10 ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/round10/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round10/examples/index.js index 8793b05f684b..54e1af0467b9 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round10/examples/index.js @@ -18,15 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var round10 = require( './../lib' ); -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - v = round10( x ); - console.log( 'x: %d. Rounded: %d.', x, v ); -} +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, round10 ); diff --git a/lib/node_modules/@stdlib/math/base/special/round2/README.md b/lib/node_modules/@stdlib/math/base/special/round2/README.md index ca51f3e86f2e..3cd0f351f932 100644 --- a/lib/node_modules/@stdlib/math/base/special/round2/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round2/README.md @@ -83,18 +83,16 @@ v = round2( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var round2 = require( '@stdlib/math/base/special/round2' ); -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - v = round2( x ); - console.log( 'Value: %d. Rounded: %d.', x, v ); -} +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, round2 ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/round2/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round2/examples/index.js index 7e264106178d..889e558f6db3 100644 --- a/lib/node_modules/@stdlib/math/base/special/round2/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round2/examples/index.js @@ -18,15 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var round2 = require( './../lib' ); -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - v = round2( x ); - console.log( 'x: %d. Rounded: %d.', x, v ); -} +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, round2 ); diff --git a/lib/node_modules/@stdlib/math/base/special/roundf/README.md b/lib/node_modules/@stdlib/math/base/special/roundf/README.md index b810c91706e3..bcc091c5d154 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundf/README.md @@ -90,16 +90,16 @@ v = roundf( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var roundf = require( '@stdlib/math/base/special/roundf' ); -var x; -var i; +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = ( randu() * 100.0 ) - 50.0; - console.log( 'Value: %d. Rounded: %d.', x, roundf( x ) ); -} +logEachMap( 'Value: %0.4f. Rounded: %0.4f.', x, roundf ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/roundf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/roundf/examples/index.js index c40a3a90fb29..263000f4fd93 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/roundf/examples/index.js @@ -18,13 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var roundf = require( './../lib' ); -var x; -var i; +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = ( randu() * 100.0) - 50.0; - console.log( 'Value: %d. Rounded: %d.', x, roundf( x ) ); -} +logEachMap( 'Value: %0.4f. Rounded: %0.4f.', x, roundf ); diff --git a/lib/node_modules/@stdlib/math/base/special/roundn/README.md b/lib/node_modules/@stdlib/math/base/special/roundn/README.md index 302c67209dbb..8ba552480b04 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundn/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundn/README.md @@ -78,20 +78,18 @@ v = roundn( 12368.0, 3 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var roundn = require( '@stdlib/math/base/special/roundn' ); -var x; -var n; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); +var n = discreteUniform( 100, -5, 0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - n = roundn( randu()*5.0, 0 ); - v = roundn( x, -n ); - console.log( 'x: %d. Number of decimals: %d. Rounded: %d.', x, n, v ); -} +logEachMap( 'x: %0.4f. Number of decimals: %d. Rounded: %0.4f.', x, n, roundn ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/roundn/examples/index.js b/lib/node_modules/@stdlib/math/base/special/roundn/examples/index.js index 4d213e63f394..5691e26bd233 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundn/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/roundn/examples/index.js @@ -18,17 +18,15 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var roundn = require( './../lib' ); -var x; -var n; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); +var n = discreteUniform( 100, -5, 0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - n = roundn( randu()*5.0, 0 ); - v = roundn( x, -n ); - console.log( 'x: %d. Number of decimals: %d. Rounded: %d.', x, n, v ); -} +logEachMap( 'x: %0.4f. Number of decimals: %d. Rounded: %0.4f.', x, n, roundn ); From d9e3dbe2bae0ca7a664de724793c6d82e63bd78d Mon Sep 17 00:00:00 2001 From: hrshya Date: Tue, 1 Apr 2025 16:35:56 +0530 Subject: [PATCH 2/2] fix: resolve lint issues --- .../@stdlib/math/base/special/round10/examples/index.js | 2 +- .../@stdlib/math/base/special/round2/examples/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round10/examples/index.js index 54e1af0467b9..d3b4c89a4144 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round10/examples/index.js @@ -23,7 +23,7 @@ var logEachMap = require( '@stdlib/console/log-each-map' ); var round10 = require( './../lib' ); var opts = { - 'dtype': 'float64' + 'dtype': 'float64' }; var x = uniform( 100, -50.0, 50.0, opts ); diff --git a/lib/node_modules/@stdlib/math/base/special/round2/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round2/examples/index.js index 889e558f6db3..353ea9b9cdef 100644 --- a/lib/node_modules/@stdlib/math/base/special/round2/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round2/examples/index.js @@ -23,7 +23,7 @@ var logEachMap = require( '@stdlib/console/log-each-map' ); var round2 = require( './../lib' ); var opts = { - 'dtype': 'float64' + 'dtype': 'float64' }; var x = uniform( 100, -50.0, 50.0, opts );