Skip to content

Commit c014264

Browse files
committed
fix: ensure acschf consistency with acsch package
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - 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: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - 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 ddec403 commit c014264

6 files changed

Lines changed: 28 additions & 20 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ bench( pkg, function benchmark( b ) {
4646
}
4747
}
4848
b.toc();
49-
5049
if ( isnanf( y ) ) {
5150
b.fail( 'should not return NaN' );
5251
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ bench( format( '%s::native', pkg ), opts, function benchmark( b ) {
4444
var y;
4545
var i;
4646

47-
// Generate input data once (valid domain: |x| >= 1)
48-
x = uniform( 100, 1.0, 50.0, {
47+
x = uniform( 100, -50.0, 50.0, {
4948
'dtype': 'float32'
5049
});
5150

@@ -57,7 +56,6 @@ bench( format( '%s::native', pkg ), opts, function benchmark( b ) {
5756
}
5857
}
5958
b.toc();
60-
6159
if ( isnanf( y ) ) {
6260
b.fail( 'should not return NaN' );
6361
}

lib/node_modules/@stdlib/math/base/special/acschf/test/fixtures/julia/runner.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ function gen( domain, name )
5151
# Write the data to the output filepath as JSON:
5252
outfile = open( filepath, "w" );
5353
json_str = JSON.json(data; allownan=true);
54-
# Replace Infinity with string representation for JSON compatibility
55-
json_str = replace(json_str, "Infinity" => "\"Infinity\"");
56-
json_str = replace(json_str, "-Infinity" => "\"-Infinity\"");
54+
json_str = replace(json_str, "-Infinity" => "null");
55+
json_str = replace(json_str, "Infinity" => "null");
5756
write( outfile, json_str );
5857
write( outfile, "\n" );
5958
close( outfile );

lib/node_modules/@stdlib/math/base/special/acschf/test/fixtures/julia/smaller.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acschf/test/test.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
2626
var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' );
2727
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
2828
var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
29+
var PINF = require( '@stdlib/constants/float32/pinf' );
30+
var NINF = require( '@stdlib/constants/float32/ninf' );
2931
var acschf = require( './../lib' );
3032

3133

@@ -102,8 +104,12 @@ tape( 'the function computes the hyperbolic arccosecant on the interval `[-0.8,0
102104

103105
for ( i = 0; i < x.length; i++ ) {
104106
y = acschf( float64ToFloat32( x[i] ) );
105-
e = float64ToFloat32( expected[ i ] );
106-
t.strictEqual( isAlmostSameValue( y, e, 3 ), true, 'x: '+x[i]+'. y: '+y+'. E: '+e+'.' );
107+
if ( expected[ i ] === null ) {
108+
t.strictEqual( y, PINF, 'x: '+x[i]+'. E: +infinity' );
109+
} else {
110+
e = float64ToFloat32( expected[ i ] );
111+
t.strictEqual( isAlmostSameValue( y, e, 3 ), true, 'x: '+x[i]+'. y: '+y+'. E: '+e+'.' );
112+
}
107113
}
108114
t.end();
109115
});
@@ -296,24 +302,24 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
296302

297303
tape( 'the function returns `+infinity` if provided `+0`', function test( t ) {
298304
var v = acschf( +0.0 );
299-
t.strictEqual( v, float64ToFloat32( Infinity ), 'returns expected value' );
305+
t.strictEqual( v, PINF, 'returns expected value' );
300306
t.end();
301307
});
302308

303309
tape( 'the function returns `-infinity` if provided `-0`', function test( t ) {
304310
var v = acschf( -0.0 );
305-
t.strictEqual( v, float64ToFloat32( -Infinity ), 'returns expected value' );
311+
t.strictEqual( v, NINF, 'returns expected value' );
306312
t.end();
307313
});
308314

309315
tape( 'the function returns `-0` if provided `-infinity`', function test( t ) {
310-
var v = acschf( float64ToFloat32( -Infinity ) );
316+
var v = acschf( NINF );
311317
t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' );
312318
t.end();
313319
});
314320

315321
tape( 'the function returns `+0` if provided `+infinity`', function test( t ) {
316-
var v = acschf( float64ToFloat32( Infinity ) );
322+
var v = acschf( PINF );
317323
t.strictEqual( isPositiveZerof( v ), true, 'returns expected value' );
318324
t.end();
319325
});

lib/node_modules/@stdlib/math/base/special/acschf/test/test.native.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
2727
var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' );
2828
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
2929
var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
30+
var PINF = require( '@stdlib/constants/float32/pinf' );
31+
var NINF = require( '@stdlib/constants/float32/ninf' );
3032
var tryRequire = require( '@stdlib/utils/try-require' );
3133

3234

@@ -111,8 +113,12 @@ tape( 'the function computes the hyperbolic arccosecant on the interval `[-0.8,0
111113

112114
for ( i = 0; i < x.length; i++ ) {
113115
y = acschf( float64ToFloat32( x[i] ) );
114-
e = float64ToFloat32( expected[ i ] );
115-
t.strictEqual( isAlmostSameValue( y, e, 3 ), true, 'x: '+x[i]+'. y: '+y+'. E: '+e+'.' );
116+
if ( expected[ i ] === null ) {
117+
t.strictEqual( y, PINF, 'x: '+x[i]+'. E: +infinity' );
118+
} else {
119+
e = float64ToFloat32( expected[ i ] );
120+
t.strictEqual( isAlmostSameValue( y, e, 3 ), true, 'x: '+x[i]+'. y: '+y+'. E: '+e+'.' );
121+
}
116122
}
117123
t.end();
118124
});
@@ -305,24 +311,24 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
305311

306312
tape( 'the function returns `+infinity` if provided `+0`', opts, function test( t ) {
307313
var v = acschf( +0.0 );
308-
t.strictEqual( v, float64ToFloat32( Infinity ), 'returns expected value' );
314+
t.strictEqual( v, PINF, 'returns expected value' );
309315
t.end();
310316
});
311317

312318
tape( 'the function returns `-infinity` if provided `-0`', opts, function test( t ) {
313319
var v = acschf( -0.0 );
314-
t.strictEqual( v, float64ToFloat32( -Infinity ), 'returns expected value' );
320+
t.strictEqual( v, NINF, 'returns expected value' );
315321
t.end();
316322
});
317323

318324
tape( 'the function returns `-0` if provided `-infinity`', opts, function test( t ) {
319-
var v = acschf( float64ToFloat32( -Infinity ) );
325+
var v = acschf( NINF );
320326
t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' );
321327
t.end();
322328
});
323329

324330
tape( 'the function returns `+0` if provided `+infinity`', opts, function test( t ) {
325-
var v = acschf( float64ToFloat32( Infinity ) );
331+
var v = acschf( PINF );
326332
t.strictEqual( isPositiveZerof( v ), true, 'returns expected value' );
327333
t.end();
328334
});

0 commit comments

Comments
 (0)