Skip to content

Commit 3aa71c3

Browse files
committed
test: add accessor array 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: 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 101df02 commit 3aa71c3

File tree

2 files changed

+33
-56
lines changed

2 files changed

+33
-56
lines changed

lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2020 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,12 +21,11 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var floor = require( '@stdlib/math/base/special/floor' );
25-
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
2624
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2725
var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
26+
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
2827
var Float64Array = require( '@stdlib/array/float64' );
29-
var nanminBy = require( './../lib/nanmin_by.js' );
28+
var nanminBy = require( './../lib/main.js' );
3029

3130

3231
// FUNCTIONS //
@@ -76,11 +75,11 @@ tape( 'the function calculates the minimum value of a strided array via a callba
7675
v = nanminBy( x.length, x, 1, accessor );
7776
t.strictEqual( isnan( v ), true, 'returns expected value' );
7877

79-
x = new Array( 5 ); // sparse array
78+
x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
8079
v = nanminBy( x.length, x, 1, accessor );
8180
t.strictEqual( isnan( v ), true, 'returns expected value' );
8281

83-
x = new Array( 5 ); // sparse array
82+
x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
8483
x[ 2 ] = 1.0;
8584
v = nanminBy( x.length, x, 1, accessor );
8685
t.strictEqual( v, 2.0, 'returns expected value' );
@@ -112,13 +111,13 @@ tape( 'the function calculates the minimum value of a strided array via a callba
112111
v = nanminBy( x.length, toAccessorArray( x ), 1, accessor );
113112
t.strictEqual( isnan( v ), true, 'returns expected value' );
114113

115-
x = new Array( 5 ); // sparse array
114+
x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
116115
v = nanminBy( x.length, toAccessorArray( x ), 1, accessor );
117116
t.strictEqual( isnan( v ), true, 'returns expected value' );
118117

119-
x = new Array( 5 ); // sparse array
118+
x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
120119
x[ 2 ] = 1.0;
121-
v = nanminBy( x.length, toAccessorArray( x), 1, accessor );
120+
v = nanminBy( x.length, toAccessorArray( x ), 1, accessor );
122121
t.strictEqual( v, 2.0, 'returns expected value' );
123122

124123
t.end();
@@ -148,7 +147,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
148147
v = nanminBy( 0, toAccessorArray( x ), 1, accessor );
149148
t.strictEqual( isnan( v ), true, 'returns expected value' );
150149

151-
v = nanminBy( -1, x, 1, accessor );
150+
v = nanminBy( -1, toAccessorArray( x ), 1, accessor );
152151
t.strictEqual( isnan( v ), true, 'returns expected value' );
153152

154153
t.end();
@@ -163,7 +162,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
163162
v = nanminBy( 1, x, 1, accessor );
164163
t.strictEqual( v, 2.0, 'returns expected value' );
165164

166-
x = new Array( 1 ); // sparse array
165+
x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
167166
v = nanminBy( 1, x, 1, accessor );
168167
t.strictEqual( isnan( v ), true, 'returns expected value' );
169168

@@ -179,15 +178,14 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
179178
v = nanminBy( 1, toAccessorArray( x ), 1, accessor );
180179
t.strictEqual( v, 2.0, 'returns expected value' );
181180

182-
x = new Array( 1 ); // sparse array
181+
x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
183182
v = nanminBy( 1, toAccessorArray( x ), 1, accessor );
184183
t.strictEqual( isnan( v ), true, 'returns expected value' );
185184

186185
t.end();
187186
});
188187

189188
tape( 'the function supports a `stride` parameter', function test( t ) {
190-
var N;
191189
var x;
192190
var v;
193191

@@ -204,15 +202,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
204202
NaN
205203
];
206204

207-
N = floor( x.length / 2 );
208-
v = nanminBy( N, x, 2, accessor );
205+
v = nanminBy( 5, x, 2, accessor );
209206

210207
t.strictEqual( v, -4.0, 'returns expected value' );
211208
t.end();
212209
});
213210

214211
tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
215-
var N;
216212
var x;
217213
var v;
218214

@@ -229,15 +225,13 @@ tape( 'the function supports a `stride` parameter (accessors)', function test( t
229225
NaN
230226
];
231227

232-
N = floor( x.length / 2 );
233-
v = nanminBy( N, toAccessorArray( x ), 2, accessor );
228+
v = nanminBy( 5, toAccessorArray( x ), 2, accessor );
234229

235230
t.strictEqual( v, -4.0, 'returns expected value' );
236231
t.end();
237232
});
238233

239234
tape( 'the function supports a negative `stride` parameter', function test( t ) {
240-
var N;
241235
var x;
242236
var v;
243237

@@ -254,15 +248,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
254248
2.0
255249
];
256250

257-
N = floor( x.length / 2 );
258-
v = nanminBy( N, x, -2, accessor );
251+
v = nanminBy( 5, x, -2, accessor );
259252

260253
t.strictEqual( v, -4.0, 'returns expected value' );
261254
t.end();
262255
});
263256

264257
tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
265-
var N;
266258
var x;
267259
var v;
268260

@@ -279,8 +271,7 @@ tape( 'the function supports a negative `stride` parameter (accessors)', functio
279271
2.0
280272
];
281273

282-
N = floor( x.length / 2 );
283-
v = nanminBy( N, toAccessorArray( x ), -2, accessor );
274+
v = nanminBy( 5, toAccessorArray( x ), -2, accessor );
284275

285276
t.strictEqual( v, -4.0, 'returns expected value' );
286277
t.end();
@@ -295,7 +286,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
295286
v = nanminBy( x.length, x, 0, accessor );
296287
t.strictEqual( v, 2.0, 'returns expected value' );
297288

298-
x = new Array( 1 ); // sparse array
289+
x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
299290
v = nanminBy( 1, x, 0, accessor );
300291
t.strictEqual( isnan( v ), true, 'returns expected value' );
301292

@@ -311,7 +302,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
311302
v = nanminBy( x.length, toAccessorArray( x ), 0, accessor );
312303
t.strictEqual( v, 2.0, 'returns expected value' );
313304

314-
x = new Array( 1 ); // sparse array
305+
x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
315306
v = nanminBy( 1, toAccessorArray( x ), 0, accessor );
316307
t.strictEqual( isnan( v ), true, 'returns expected value' );
317308

@@ -321,7 +312,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
321312
tape( 'the function supports view offsets', function test( t ) {
322313
var x0;
323314
var x1;
324-
var N;
325315
var v;
326316

327317
x0 = new Float64Array([
@@ -339,9 +329,8 @@ tape( 'the function supports view offsets', function test( t ) {
339329
]);
340330

341331
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
342-
N = floor(x1.length / 2);
343332

344-
v = nanminBy( N, x1, 2, accessor );
333+
v = nanminBy( 5, x1, 2, accessor );
345334
t.strictEqual( v, -4.0, 'returns expected value' );
346335

347336
t.end();
@@ -350,7 +339,6 @@ tape( 'the function supports view offsets', function test( t ) {
350339
tape( 'the function supports view offsets (accessors)', function test( t ) {
351340
var x0;
352341
var x1;
353-
var N;
354342
var v;
355343

356344
x0 = new Float64Array([
@@ -368,9 +356,8 @@ tape( 'the function supports view offsets (accessors)', function test( t ) {
368356
]);
369357

370358
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
371-
N = floor(x1.length / 2);
372359

373-
v = nanminBy( N, toAccessorArray( x1 ), 2, accessor );
360+
v = nanminBy( 5, toAccessorArray( x1 ), 2, accessor );
374361
t.strictEqual( v, -4.0, 'returns expected value' );
375362

376363
t.end();

lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.ndarray.js

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2020 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,10 +21,9 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var floor = require( '@stdlib/math/base/special/floor' );
25-
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
2624
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2725
var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
26+
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
2827
var nanminBy = require( './../lib/ndarray.js' );
2928

3029

@@ -75,11 +74,11 @@ tape( 'the function calculates the minimum value of a strided array via a callba
7574
v = nanminBy( x.length, x, 1, 0, accessor );
7675
t.strictEqual( isnan( v ), true, 'returns expected value' );
7776

78-
x = new Array( 5 ); // sparse array
77+
x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
7978
v = nanminBy( x.length, x, 1, 0, accessor );
8079
t.strictEqual( isnan( v ), true, 'returns expected value' );
8180

82-
x = new Array( 5 ); // sparse array
81+
x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
8382
x[ 2 ] = 1.0;
8483
v = nanminBy( x.length, x, 1, 0, accessor );
8584
t.strictEqual( v, 2.0, 'returns expected value' );
@@ -111,11 +110,11 @@ tape( 'the function calculates the minimum value of a strided array via a callba
111110
v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor );
112111
t.strictEqual( isnan( v ), true, 'returns expected value' );
113112

114-
x = new Array( 5 ); // sparse array
113+
x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
115114
v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor );
116115
t.strictEqual( isnan( v ), true, 'returns expected value' );
117116

118-
x = new Array( 5 ); // sparse array
117+
x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
119118
x[ 2 ] = 1.0;
120119
v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor );
121120
t.strictEqual( v, 2.0, 'returns expected value' );
@@ -162,7 +161,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
162161
v = nanminBy( 1, x, 1, 0, accessor );
163162
t.strictEqual( v, 2.0, 'returns expected value' );
164163

165-
x = new Array( 1 ); // sparse array
164+
x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
166165
v = nanminBy( 1, x, 1, 0, accessor );
167166
t.strictEqual( isnan( v ), true, 'returns expected value' );
168167

@@ -178,15 +177,14 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
178177
v = nanminBy( 1, toAccessorArray( x ), 1, 0, accessor );
179178
t.strictEqual( v, 2.0, 'returns expected value' );
180179

181-
x = new Array( 1 ); // sparse array
180+
x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
182181
v = nanminBy( 1, toAccessorArray( x ), 1, 0, accessor );
183182
t.strictEqual( isnan( v ), true, 'returns expected value' );
184183

185184
t.end();
186185
});
187186

188187
tape( 'the function supports a `stride` parameter', function test( t ) {
189-
var N;
190188
var x;
191189
var v;
192190

@@ -203,15 +201,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
203201
NaN
204202
];
205203

206-
N = floor( x.length / 2 );
207-
v = nanminBy( N, x, 2, 0, accessor );
204+
v = nanminBy( 5, x, 2, 0, accessor );
208205

209206
t.strictEqual( v, -4.0, 'returns expected value' );
210207
t.end();
211208
});
212209

213210
tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
214-
var N;
215211
var x;
216212
var v;
217213

@@ -228,15 +224,13 @@ tape( 'the function supports a `stride` parameter (accessors)', function test( t
228224
NaN
229225
];
230226

231-
N = floor( x.length / 2 );
232-
v = nanminBy( N, toAccessorArray( x ), 2, 0, accessor );
227+
v = nanminBy( 5, toAccessorArray( x ), 2, 0, accessor );
233228

234229
t.strictEqual( v, -4.0, 'returns expected value' );
235230
t.end();
236231
});
237232

238233
tape( 'the function supports a negative `stride` parameter', function test( t ) {
239-
var N;
240234
var x;
241235
var v;
242236

@@ -253,15 +247,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
253247
2.0
254248
];
255249

256-
N = floor( x.length / 2 );
257-
v = nanminBy( N, x, -2, 8, accessor );
250+
v = nanminBy( 5, x, -2, 8, accessor );
258251

259252
t.strictEqual( v, -4.0, 'returns expected value' );
260253
t.end();
261254
});
262255

263256
tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
264-
var N;
265257
var x;
266258
var v;
267259

@@ -278,8 +270,7 @@ tape( 'the function supports a negative `stride` parameter (accessors)', functio
278270
2.0
279271
];
280272

281-
N = floor( x.length / 2 );
282-
v = nanminBy( N, toAccessorArray( x ), -2, 8, accessor );
273+
v = nanminBy( 5, toAccessorArray( x ), -2, 8, accessor );
283274

284275
t.strictEqual( v, -4.0, 'returns expected value' );
285276
t.end();
@@ -294,13 +285,12 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
294285
v = nanminBy( x.length, x, 0, 0, accessor );
295286
t.strictEqual( v, 2.0, 'returns expected value' );
296287

297-
x = new Array( 1 ); // sparse array
288+
x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
298289
v = nanminBy( 1, x, 0, 0, accessor );
299290
t.strictEqual( isnan( v ), true, 'returns expected value' );
300291

301292
t.end();
302293
});
303-
304294
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first accessed element (accessors)', function test( t ) {
305295
var x;
306296
var v;
@@ -310,7 +300,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
310300
v = nanminBy( x.length, toAccessorArray( x ), 0, 0, accessor );
311301
t.strictEqual( v, 2.0, 'returns expected value' );
312302

313-
x = new Array( 1 ); // sparse array
303+
x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
314304
v = nanminBy( 1, toAccessorArray( x ), 0, 0, accessor );
315305
t.strictEqual( isnan( v ), true, 'returns expected value' );
316306

0 commit comments

Comments
 (0)