-
-
Notifications
You must be signed in to change notification settings - Fork 995
docs: replace manual for loop in examples
#6472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,14 +18,13 @@ | |
|
|
||
| 'use strict'; | ||
|
|
||
| var randu = require( '@stdlib/random/base/randu' ); | ||
| var round = require( '@stdlib/math/base/special/round' ); | ||
| var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); | ||
| var logEachMap = require( '@stdlib/console/log-each-map' ); | ||
| var log10 = require( './../lib' ); | ||
|
|
||
| var x; | ||
| var i; | ||
| var opts = { | ||
| 'dtype': 'float64' | ||
| }; | ||
| var x = discreteUniform( 100, 0, 100, opts ); | ||
|
|
||
| for ( i = 0; i < 100; i++ ) { | ||
| x = round( randu() * 100.0 ); | ||
| console.log( 'log10(%d) = %d', x, log10( x ) ); | ||
| } | ||
| logEachMap( 'log10(%0.4f) = %0.4f', x, log10 ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stdlib-bot This should become
since we don't want to display decimal points for integers. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,17 +87,16 @@ var v = log2( -4.0 ); | |
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| ```javascript | ||
| var randu = require( '@stdlib/random/base/randu' ); | ||
| var round = require( '@stdlib/math/base/special/round' ); | ||
| var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); | ||
| var logEachMap = require( '@stdlib/console/log-each-map' ); | ||
| var log2 = require( '@stdlib/math/base/special/log2' ); | ||
|
|
||
| var x; | ||
| var i; | ||
| var opts = { | ||
| 'dtype': 'float64' | ||
| }; | ||
| var x = discreteUniform( 100, 0, 100, opts ); | ||
|
|
||
| for ( i = 0; i < 100; i++ ) { | ||
| x = round( randu() * 100.0 ); | ||
| console.log( 'log2(%d) = %d', x, log2( x ) ); | ||
| } | ||
| logEachMap( 'log2(%0.4f) = %0.4f', x, log2 ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stdlib-bot This should become
since we don't want to display decimal points for integers. |
||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,14 +18,13 @@ | |
|
|
||
| 'use strict'; | ||
|
|
||
| var randu = require( '@stdlib/random/base/randu' ); | ||
| var round = require( '@stdlib/math/base/special/round' ); | ||
| var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); | ||
| var logEachMap = require( '@stdlib/console/log-each-map' ); | ||
| var log2 = require( './../lib' ); | ||
|
|
||
| var x; | ||
| var i; | ||
| var opts = { | ||
| 'dtype': 'float64' | ||
| }; | ||
| var x = discreteUniform( 100, 0, 100, opts ); | ||
|
|
||
| for ( i = 0; i < 100; i++ ) { | ||
| x = round( randu() * 100.0 ); | ||
| console.log( 'log2(%d) = %d', x, log2( x ) ); | ||
| } | ||
| logEachMap( 'log2(%0.4f) = %0.4f', x, log2 ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stdlib-bot This should become
since we don't want to display decimal points for integers. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,20 +66,17 @@ v = logf( 2.0, -4.0 ); | |
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| ```javascript | ||
| var randu = require( '@stdlib/random/array/discrete-uniform' ); | ||
| var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); | ||
| var logEachMap = require( '@stdlib/console/log-each-map' ); | ||
| var logf = require( '@stdlib/math/base/special/logf' ); | ||
|
|
||
| var opts = { | ||
| 'dtype': 'float32' | ||
| }; | ||
| var x = discreteUniform( 100, 0, 100, opts ); | ||
| var b = discreteUniform( 100, 0, 5, opts ); | ||
|
|
||
| var x = randu( 100, 0, 100, opts ); | ||
| var b = randu( 100, 0, 5, opts ); | ||
|
|
||
| var i; | ||
| for ( i = 0; i < 100; i++ ) { | ||
| console.log( 'logf( %d, %d ) = %d', x[ i ], b[ i ], logf( x[ i ], b[ i ] ) ); | ||
| } | ||
| logEachMap( 'logf( %0.4f, %0.4f ) = %0.4f', x, b, logf ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stdlib-bot This should become
since we don't want to display decimal points for integers. |
||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,17 +18,14 @@ | |
|
|
||
| 'use strict'; | ||
|
|
||
| var randu = require( '@stdlib/random/array/discrete-uniform' ); | ||
| var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); | ||
| var logEachMap = require( '@stdlib/console/log-each-map' ); | ||
| var logf = require( './../lib' ); | ||
|
|
||
| var opts = { | ||
| 'dtype': 'float32' | ||
| }; | ||
| var x = discreteUniform( 100, 0, 100, opts ); | ||
| var b = discreteUniform( 100, 0, 5, opts ); | ||
|
|
||
| var x = randu( 100, 0, 100, opts ); | ||
| var b = randu( 100, 0, 5, opts ); | ||
|
|
||
| var i; | ||
| for ( i = 0; i < 100; i++ ) { | ||
| console.log( 'logf( %d, %d ) = %d', x[ i ], b[ i ], logf( x[ i ], b[ i ] ) ); | ||
| } | ||
| logEachMap( 'logf( %0.4f, %0.4f ) = %0.4f', x, b, logf ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stdlib-bot This should become
since we don't want to display decimal points for integers. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stdlib-bot This should become
logEachMap( 'log10(%d) = %0.4f', x, log10 );since we don't want to display decimal points for integers.