Skip to content

Commit 5ac2354

Browse files
committed
test: remove redundant fixtures and update tests
--- 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: na - task: lint_python status: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8dc25bb commit 5ac2354

File tree

9 files changed

+15
-168
lines changed

9 files changed

+15
-168
lines changed

lib/node_modules/@stdlib/math/base/special/gammasgn/test/fixtures/python/data.json

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

lib/node_modules/@stdlib/math/base/special/gammasgn/test/fixtures/python/medium_negative.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/node_modules/@stdlib/math/base/special/gammasgn/test/fixtures/python/medium_positive.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/node_modules/@stdlib/math/base/special/gammasgn/test/fixtures/python/random.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/node_modules/@stdlib/math/base/special/gammasgn/test/fixtures/python/runner.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def gen(x, name):
4545
```
4646
"""
4747
y = gammasgn(x)
48+
49+
# Convert all NaN values to 0 according to our convention:
50+
y[np.isnan(y)] = 0
51+
4852
data = {
4953
"x": x.tolist(),
5054
"expected": y.tolist()
@@ -60,25 +64,8 @@ def gen(x, name):
6064

6165
def main():
6266
"""Generate fixture data."""
63-
# Random values across `x`:
64-
x = np.random.random(1000)*100.0
65-
gen(x, "random.json")
66-
67-
# Medium negative:
68-
x = np.linspace(-709.78, -1.0, 1000)
69-
gen(x, "medium_negative.json")
70-
71-
# Medium positive:
72-
x = np.linspace(1.0, 709.78, 1000)
73-
gen(x, "medium_positive.json")
74-
75-
# Small positive:
76-
x = np.linspace(2.0**-54, 1.0, 1000)
77-
gen(x, "small_positive.json")
78-
79-
# Small negative:
80-
x = np.linspace(-1.0, -2.0**-54, 1000)
81-
gen(x, "small_negative.json")
67+
x = np.random.uniform(-1000, 1000, 2001)
68+
gen(x, "data.json")
8269

8370

8471
if __name__ == "__main__":

lib/node_modules/@stdlib/math/base/special/gammasgn/test/fixtures/python/small_negative.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/node_modules/@stdlib/math/base/special/gammasgn/test/fixtures/python/small_positive.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ var gammasgn = require( './../lib' );
2828

2929
// FIXTURES //
3030

31-
var random = require( './fixtures/python/random.json' );
32-
var mediumNegative = require( './fixtures/python/medium_negative.json' );
33-
var mediumPositive = require( './fixtures/python/medium_positive.json' );
34-
var smallPositive = require( './fixtures/python/small_positive.json' );
35-
var smallNegative = require( './fixtures/python/small_negative.json' );
31+
var data = require( './fixtures/python/data.json' );
3632

3733

3834
// TESTS //
@@ -49,76 +45,12 @@ tape( 'the function computes the sign of the gamma function', function test( t )
4945
var v;
5046
var i;
5147

52-
x = random.x;
53-
expected = random.expected;
48+
x = data.x;
49+
expected = data.expected;
5450

5551
for ( i = 0; i < x.length; i++ ) {
5652
v = gammasgn( x[ i ] );
57-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
58-
}
59-
t.end();
60-
});
61-
62-
tape( 'the function computes the sign of the gamma function for small positive numbers', function test( t ) {
63-
var expected;
64-
var x;
65-
var v;
66-
var i;
67-
68-
x = smallPositive.x;
69-
expected = smallPositive.expected;
70-
71-
for ( i = 0; i < x.length; i++ ) {
72-
v = gammasgn( x[ i ] );
73-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
74-
}
75-
t.end();
76-
});
77-
78-
tape( 'the function computes the sign of the gamma function for medium positive numbers', function test( t ) {
79-
var expected;
80-
var x;
81-
var v;
82-
var i;
83-
84-
x = mediumPositive.x;
85-
expected = mediumPositive.expected;
86-
87-
for ( i = 0; i < x.length; i++ ) {
88-
v = gammasgn( x[ i ] );
89-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
90-
}
91-
t.end();
92-
});
93-
94-
tape( 'the function computes the sign of the gamma function for small negative numbers', function test( t ) {
95-
var expected;
96-
var x;
97-
var v;
98-
var i;
99-
100-
x = smallNegative.x;
101-
expected = smallNegative.expected;
102-
103-
for ( i = 0; i < x.length; i++ ) {
104-
v = gammasgn( x[ i ] );
105-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
106-
}
107-
t.end();
108-
});
109-
110-
tape( 'the function computes the sign of the gamma function for medium negative numbers', function test( t ) {
111-
var expected;
112-
var x;
113-
var v;
114-
var i;
115-
116-
x = mediumNegative.x;
117-
expected = mediumNegative.expected;
118-
119-
for ( i = 0; i < x.length; i++ ) {
120-
v = gammasgn( x[ i ] );
121-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
53+
t.strictEqual( v, expected[ i ], 'returns expected value' );
12254
}
12355
t.end();
12456
});

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

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ var opts = {
3737

3838
// FIXTURES //
3939

40-
var random = require( './fixtures/python/random.json' );
41-
var mediumNegative = require( './fixtures/python/medium_negative.json' );
42-
var mediumPositive = require( './fixtures/python/medium_positive.json' );
43-
var smallPositive = require( './fixtures/python/small_positive.json' );
44-
var smallNegative = require( './fixtures/python/small_negative.json' );
40+
var data = require( './fixtures/python/data.json' );
4541

4642

4743
// TESTS //
@@ -58,76 +54,12 @@ tape( 'the function computes the sign of the gamma function', opts, function tes
5854
var v;
5955
var i;
6056

61-
x = random.x;
62-
expected = random.expected;
57+
x = data.x;
58+
expected = data.expected;
6359

6460
for ( i = 0; i < x.length; i++ ) {
6561
v = gammasgn( x[ i ] );
66-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
67-
}
68-
t.end();
69-
});
70-
71-
tape( 'the function computes the sign of the gamma function for small positive numbers', opts, function test( t ) {
72-
var expected;
73-
var x;
74-
var v;
75-
var i;
76-
77-
x = smallPositive.x;
78-
expected = smallPositive.expected;
79-
80-
for ( i = 0; i < x.length; i++ ) {
81-
v = gammasgn( x[ i ] );
82-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
83-
}
84-
t.end();
85-
});
86-
87-
tape( 'the function computes the sign of the gamma function for medium positive numbers', opts, function test( t ) {
88-
var expected;
89-
var x;
90-
var v;
91-
var i;
92-
93-
x = mediumPositive.x;
94-
expected = mediumPositive.expected;
95-
96-
for ( i = 0; i < x.length; i++ ) {
97-
v = gammasgn( x[ i ] );
98-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
99-
}
100-
t.end();
101-
});
102-
103-
tape( 'the function computes the sign of the gamma function for small negative numbers', opts, function test( t ) {
104-
var expected;
105-
var x;
106-
var v;
107-
var i;
108-
109-
x = smallNegative.x;
110-
expected = smallNegative.expected;
111-
112-
for ( i = 0; i < x.length; i++ ) {
113-
v = gammasgn( x[ i ] );
114-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
115-
}
116-
t.end();
117-
});
118-
119-
tape( 'the function computes the sign of the gamma function for medium negative numbers', opts, function test( t ) {
120-
var expected;
121-
var x;
122-
var v;
123-
var i;
124-
125-
x = mediumNegative.x;
126-
expected = mediumNegative.expected;
127-
128-
for ( i = 0; i < x.length; i++ ) {
129-
v = gammasgn( x[ i ] );
130-
t.strictEqual( v, expected[ i ], 'x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '.' );
62+
t.strictEqual( v, expected[ i ], 'returns expected value' );
13163
}
13264
t.end();
13365
});

0 commit comments

Comments
 (0)