Skip to content

Commit a36eaf0

Browse files
committed
refactor: apply suggestions from PR review
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent aef955f commit a36eaf0

File tree

18 files changed

+120
-116
lines changed

18 files changed

+120
-116
lines changed

lib/node_modules/@stdlib/math/base/special/wrapf/README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# wrapf
2222

23-
> Wrap a value on the half-open interval `[min,max)` for single-precision floating-point numbers.
23+
> Wrap a single-precision floating-point value to the half-open interval `[min,max)`.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -42,7 +42,7 @@ var wrapf = require( '@stdlib/math/base/special/wrapf' );
4242

4343
#### wrapf( v, min, max )
4444

45-
Wrap a value on the half-open interval `[min,max)` for single-precision floating-point numbers.
45+
Wraps a single-precision floating-point value to the half-open interval `[min,max)`.
4646

4747
```javascript
4848
var v = wrapf( 3.14, 0.0, 5.0 );
@@ -106,20 +106,18 @@ var v = wrapf( 3.14, 3.0, 3.0 );
106106
<!-- eslint no-undef: "error" -->
107107

108108
```javascript
109-
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
109+
var uniform = require( '@stdlib/random/array/uniform' );
110+
var logEachMap = require( '@stdlib/console/log-each-map' );
110111
var wrapf = require( '@stdlib/math/base/special/wrapf' );
111112

112-
var min;
113-
var max;
114-
var v;
115-
var i;
113+
var opts = {
114+
'dtype': 'float32'
115+
};
116+
var min = uniform( 100, 0.0, 10.0, opts );
117+
var max = uniform( 100, 5.0, 15.0, opts );
118+
var v = uniform( 100, -20.0, 20.0, opts );
116119

117-
for ( i = 0; i < 100; i++ ) {
118-
min = discreteUniform( 0.0, 10.0 );
119-
max = discreteUniform( 5.0, 15.0 );
120-
v = discreteUniform( -20.0, 20.0 );
121-
console.log( 'wrapf(%d,%d,%d) => %d', v, min, max, wrapf( v, min, max ) );
122-
}
120+
logEachMap( 'wrapf(%0.4f,%0.4f,%0.4f) => %0.4f', v, min, max, wrapf );
123121
```
124122

125123
</section>
@@ -154,14 +152,14 @@ for ( i = 0; i < 100; i++ ) {
154152

155153
#### stdlib_base_wrapf( v, min, max )
156154

157-
Wraps a value on the half-open interval `[min,max)` for single-precision floating-point numbers.
155+
Wrap a single-precision floating-point value to the half-open interval `[min,max)`.
158156

159157
```c
160-
float v = stdlib_base_wrapf( 3.14, 0.0, 5.0 );
161-
// returns ~3.14
158+
float v = stdlib_base_wrapf( 3.14f, 0.0f, 5.0f );
159+
// returns ~3.14f
162160

163-
v = stdlib_base_wrapf( -3.14, 0.0, 5.0 );
164-
// returns ~1.86
161+
v = stdlib_base_wrapf( -3.14f, 0.0f, 5.0f );
162+
// returns ~1.86f
165163
```
166164

167165
The function accepts the following arguments:

lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/array/uniform' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var pkg = require( './../package.json' ).name;
2727
var wrapf = require( './../lib' );
@@ -34,7 +34,9 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37-
x = randu( 100, -10.0, 10.0 );
37+
x = uniform( 100, -10.0, 10.0, {
38+
'dtype': 'float32'
39+
});
3840

3941
b.tic();
4042
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.native.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/array/uniform' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2626
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -43,7 +43,9 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46-
x = randu( 100, -10.0, 10.0 );
46+
x = uniform( 100, -10.0, 10.0, {
47+
'dtype': 'float32'
48+
});
4749

4850
b.tic();
4951
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static float rand_float( void ) {
8989
* @param v value to wrap
9090
* @param min minimum value
9191
* @param max maximum value
92-
* @return wrapped value
92+
* @return wrapped value
9393
*/
9494
float wrapf( float v, float min, float max ) {
9595
float delta;
@@ -99,9 +99,9 @@ float wrapf( float v, float min, float max ) {
9999
// Perform range reduction...
100100
delta = max - min;
101101
if ( v < min ) {
102-
v += delta * ( truncf( ( min - v ) / delta ) + 1.0 );
102+
v += delta * ( truncf( (min-v)/delta ) + 1.0f );
103103
}
104-
return min + fmodf( ( v - min ), delta );
104+
return min + fmodf( (v-min), delta );
105105
}
106106

107107
/**
@@ -111,18 +111,18 @@ float wrapf( float v, float min, float max ) {
111111
*/
112112
static double benchmark( void ) {
113113
double elapsed;
114-
double t;
115114
float x[ 100 ];
115+
double t;
116116
float y;
117117
int i;
118118

119119
for ( i = 0; i < 100; i++ ) {
120-
x[ i ] = ( 20.0f * rand_float() ) - 10.0f;
120+
x[ i ] = ( 20.0f*rand_float() ) - 10.0f;
121121
}
122122

123123
t = tic();
124124
for ( i = 0; i < ITERATIONS; i++ ) {
125-
y = wrapf( x[ i%100 ], -5.0, 5.0 );
125+
y = wrapf( x[ i%100 ], -5.0f, 5.0f );
126126
if ( y != y ) {
127127
printf( "should not return NaN\n" );
128128
break;

lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/benchmark.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ static float rand_float( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double t;
9594
float x[ 100 ];
95+
double t;
9696
float y;
9797
int i;
9898

9999
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( 20.0f * rand_float() ) - 10.0f;
100+
x[ i ] = ( 20.0f*rand_float() ) - 10.0f;
101101
}
102102

103103
t = tic();
104104
for ( i = 0; i < ITERATIONS; i++ ) {
105-
y = stdlib_base_wrapf( x[ i%100 ], -5.0, 5.0 );
105+
y = stdlib_base_wrapf( x[ i%100 ], -5.0f, 5.0f );
106106
if ( y != y ) {
107107
printf( "should not return NaN\n" );
108108
break;

lib/node_modules/@stdlib/math/base/special/wrapf/docs/repl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{{alias}}( v, min, max )
3-
Wraps a value on the half-open interval `[min,max)` for single-precision
4-
floating-point numbers.
3+
Wraps a single-precision floating-point value to the half-open interval
4+
`[min,max)`.
55

66
The function does not distinguish between positive and negative zero. Where
77
appropriate, the function returns positive zero.

lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// TypeScript Version: 4.1
2020

2121
/**
22-
* Wraps a value on the half-open interval `[min,max)` for single-precision floating-point numbers.
22+
* Wraps a single-precision floating-point value to the half-open interval `[min,max)`.
2323
*
2424
* @param v - input value
2525
* @param min - minimum value

lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ int main( void ) {
2828
int i;
2929
for ( i = 0; i < 5; i++ ) {
3030
out = stdlib_base_wrapf( v[i], min[i], max[i] );
31-
printf( "wrap(%f,%f,%f) => %f\n", v[i], min[i], max[i], out );
31+
printf( "wrapf(%f,%f,%f) => %f\n", v[i], min[i], max[i], out );
3232
}
3333
}

lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@
1818

1919
'use strict';
2020

21-
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var wrapf = require( './../lib' );
2324

24-
var min;
25-
var max;
26-
var v;
27-
var i;
25+
var opts = {
26+
'dtype': 'float32'
27+
};
28+
var min = uniform( 100, 0.0, 10.0, opts );
29+
var max = uniform( 100, 5.0, 15.0, opts );
30+
var v = uniform( 100, -20.0, 20.0, opts );
2831

29-
for ( i = 0; i < 100; i++ ) {
30-
min = discreteUniform( 0.0, 10.0 );
31-
max = discreteUniform( 5.0, 15.0 );
32-
v = discreteUniform( -20.0, 20.0 );
33-
console.log( 'wrapf(%d,%d,%d) => %d', v, min, max, wrapf( v, min, max ) );
34-
}
32+
logEachMap( 'wrapf(%0.4f,%0.4f,%0.4f) => %0.4f', v, min, max, wrapf );

lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Wraps a value on the half-open interval [min,max) for single-precision floating-point numbers.
30+
* Wraps a single-precision floating-point value to the half-open interval [min,max).
3131
*/
3232
float stdlib_base_wrapf( const float v, const float min, const float max );
3333

0 commit comments

Comments
 (0)