Skip to content

Commit 0c85b4d

Browse files
committed
feat: add ndarray/index
--- 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: 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: passed - task: lint_license_headers status: passed ---
1 parent cc7c111 commit 0c85b4d

32 files changed

+7051
-0
lines changed

lib/node_modules/@stdlib/ndarray/index/README.md

Lines changed: 599 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var zeros = require( '@stdlib/ndarray/zeros' );
25+
var empty = require( '@stdlib/ndarray/empty' );
26+
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
27+
var pkg = require( './../package.json' ).name;
28+
var ndindex = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
bench( pkg+':data', function benchmark( b ) {
34+
var values;
35+
var opts;
36+
var v1;
37+
var v2;
38+
var v3;
39+
var v;
40+
var i;
41+
42+
opts = {
43+
'persist': true
44+
};
45+
46+
v1 = zeros( [ 2 ], {
47+
'dtype': 'int32'
48+
});
49+
v2 = zeros( [ 2, 2 ], {
50+
'dtype': 'int32'
51+
});
52+
v3 = empty( [ 10 ], {
53+
'dtype': 'bool'
54+
});
55+
values = [
56+
new ndindex( v1, opts ),
57+
new ndindex( v2, opts ),
58+
new ndindex( v3, opts )
59+
];
60+
61+
b.tic();
62+
for ( i = 0; i < b.iterations; i++ ) {
63+
v = values[ i%values.length ].data;
64+
if ( typeof v !== 'object' ) {
65+
b.fail( 'should return an object' );
66+
}
67+
}
68+
b.toc();
69+
if ( !isndarrayLike( v ) ) {
70+
b.fail( 'should return an ndarray' );
71+
}
72+
b.pass( 'benchmark finished' );
73+
b.end();
74+
});
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var zeros = require( '@stdlib/ndarray/zeros' );
25+
var empty = require( '@stdlib/ndarray/empty' );
26+
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
27+
var pkg = require( './../package.json' ).name;
28+
var ndindex = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
bench( pkg+':dtype', function benchmark( b ) {
34+
var values;
35+
var opts;
36+
var v1;
37+
var v2;
38+
var v3;
39+
var v;
40+
var i;
41+
42+
opts = {
43+
'persist': true
44+
};
45+
46+
v1 = zeros( [ 2 ], {
47+
'dtype': 'int32'
48+
});
49+
v2 = zeros( [ 2, 2 ], {
50+
'dtype': 'int32'
51+
});
52+
v3 = empty( [ 10 ], {
53+
'dtype': 'bool'
54+
});
55+
values = [
56+
new ndindex( v1, opts ),
57+
new ndindex( v2, opts ),
58+
new ndindex( v3, opts )
59+
];
60+
61+
b.tic();
62+
for ( i = 0; i < b.iterations; i++ ) {
63+
v = values[ i%values.length ].dtype;
64+
if ( typeof v !== 'string' ) {
65+
b.fail( 'should return a string' );
66+
}
67+
}
68+
b.toc();
69+
if ( !isString( v ) ) {
70+
b.fail( 'should return a string' );
71+
}
72+
b.pass( 'benchmark finished' );
73+
b.end();
74+
});
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var zeros = require( '@stdlib/ndarray/zeros' );
25+
var empty = require( '@stdlib/ndarray/empty' );
26+
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
27+
var pkg = require( './../package.json' ).name;
28+
var ndindex = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
bench( pkg+':get', function benchmark( b ) {
34+
var values;
35+
var opts;
36+
var v1;
37+
var v2;
38+
var v3;
39+
var v;
40+
var i;
41+
42+
opts = {
43+
'persist': true
44+
};
45+
46+
v1 = zeros( [ 2 ], {
47+
'dtype': 'int32'
48+
});
49+
v2 = zeros( [ 2, 2 ], {
50+
'dtype': 'int32'
51+
});
52+
v3 = empty( [ 10 ], {
53+
'dtype': 'bool'
54+
});
55+
values = [
56+
( new ndindex( v1, opts ) ).id,
57+
( new ndindex( v2, opts ) ).id,
58+
( new ndindex( v3, opts ) ).id
59+
];
60+
61+
b.tic();
62+
for ( i = 0; i < b.iterations; i++ ) {
63+
v = ndindex.get( values[ i%values.length ] );
64+
if ( typeof v !== 'object' ) {
65+
b.fail( 'should return an object' );
66+
}
67+
}
68+
b.toc();
69+
if ( !isPlainObject( v ) ) {
70+
b.fail( 'should return an object' );
71+
}
72+
b.pass( 'benchmark finished' );
73+
b.end();
74+
});
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var zeros = require( '@stdlib/ndarray/zeros' );
25+
var empty = require( '@stdlib/ndarray/empty' );
26+
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
27+
var pkg = require( './../package.json' ).name;
28+
var ndindex = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
bench( pkg+':id', function benchmark( b ) {
34+
var values;
35+
var opts;
36+
var v1;
37+
var v2;
38+
var v3;
39+
var v;
40+
var i;
41+
42+
opts = {
43+
'persist': true
44+
};
45+
46+
v1 = zeros( [ 2 ], {
47+
'dtype': 'int32'
48+
});
49+
v2 = zeros( [ 2, 2 ], {
50+
'dtype': 'int32'
51+
});
52+
v3 = empty( [ 10 ], {
53+
'dtype': 'bool'
54+
});
55+
values = [
56+
new ndindex( v1, opts ),
57+
new ndindex( v2, opts ),
58+
new ndindex( v3, opts )
59+
];
60+
61+
b.tic();
62+
for ( i = 0; i < b.iterations; i++ ) {
63+
v = values[ i%values.length ].id;
64+
if ( typeof v !== 'string' ) {
65+
b.fail( 'should return a string' );
66+
}
67+
}
68+
b.toc();
69+
if ( !isString( v ) ) {
70+
b.fail( 'should return a string' );
71+
}
72+
b.pass( 'benchmark finished' );
73+
b.end();
74+
});
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var zeros = require( '@stdlib/ndarray/zeros' );
25+
var empty = require( '@stdlib/ndarray/empty' );
26+
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
27+
var pkg = require( './../package.json' ).name;
28+
var ndindex = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
bench( pkg+':isCached', function benchmark( b ) {
34+
var values;
35+
var opts;
36+
var v1;
37+
var v2;
38+
var v3;
39+
var v;
40+
var i;
41+
42+
opts = {
43+
'persist': true
44+
};
45+
46+
v1 = zeros( [ 2 ], {
47+
'dtype': 'int32'
48+
});
49+
v2 = zeros( [ 2, 2 ], {
50+
'dtype': 'int32'
51+
});
52+
v3 = empty( [ 10 ], {
53+
'dtype': 'bool'
54+
});
55+
values = [
56+
new ndindex( v1, opts ),
57+
new ndindex( v2, opts ),
58+
new ndindex( v3, opts )
59+
];
60+
61+
b.tic();
62+
for ( i = 0; i < b.iterations; i++ ) {
63+
v = values[ i%values.length ].isCached;
64+
if ( typeof v !== 'boolean' ) {
65+
b.fail( 'should return a boolean' );
66+
}
67+
}
68+
b.toc();
69+
if ( !isBoolean( v ) ) {
70+
b.fail( 'should return a boolean' );
71+
}
72+
b.pass( 'benchmark finished' );
73+
b.end();
74+
});

0 commit comments

Comments
 (0)