Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Nov 1, 2023
1 parent f74614b commit dec062b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 185 deletions.
1 change: 1 addition & 0 deletions .github/.keepalive
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-11-01T01:22:13.927Z
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,38 @@ jobs:
rm -f docs/repl.txt
rm -f docs/types/test.ts
# Replace all stdlib GitHub dependencies with the respective npm packages:
- name: 'Replace all stdlib GitHub dependencies with the respective npm packages'
run: |
for dep in $(jq -r '.dependencies | keys | .[]' package.json); do
if [[ "$dep" != "@stdlib"* ]]; then
continue
fi
# Trim leading and trailing whitespace:
dep=$(echo "$dep" | xargs)
version="$(npm view $dep version)"
if [[ -z "$version" ]]; then
continue
fi
version="^$version"
jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp
mv package.json.tmp package.json
done
for dep in $(jq -r '.devDependencies | keys | .[]' package.json); do
if [[ "$dep" != "@stdlib"* ]]; then
continue
fi
# Trim leading and trailing whitespace:
dep=$(echo "$dep" | xargs)
version="$(npm view $dep version)"
if [[ -z "$version" ]]; then
continue
fi
version="^$version"
jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp
mv package.json.tmp package.json
done
# Publish package to npm:
- name: 'Publish package to npm'
# Pin action to full length commit SHA corresponding to v2.2.2
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Stephannie Jiménez Gacha <[email protected]>
Yernar Yergaziyev <[email protected]>
orimiles5 <[email protected]>
rei2hu <[email protected]>
Robert Gislason <[email protected]>
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-offset.svg
[npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-offset

[test-image]: https://github.com/stdlib-js/ndarray-base-offset/actions/workflows/test.yml/badge.svg?branch=v0.1.0
[test-url]: https://github.com/stdlib-js/ndarray-base-offset/actions/workflows/test.yml?query=branch:v0.1.0
[test-image]: https://github.com/stdlib-js/ndarray-base-offset/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/ndarray-base-offset/actions/workflows/test.yml?query=branch:main

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-offset/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-offset?branch=v0.1.0
[coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-offset?branch=main

<!--
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
},
"devDependencies": {
"@stdlib/array-base-zeros": "^0.1.1",
"@stdlib/array-float64": "^0.1.0",
"@stdlib/array-float64": "^0.1.1",
"@stdlib/bench": "^0.1.0",
"@stdlib/ndarray-ctor": "^0.1.0",
"@stdlib/ndarray-slice": "github:stdlib-js/ndarray-slice#main",
"@stdlib/ndarray-slice": "^0.1.0",
"@stdlib/ndarray-zeros": "^0.1.0",
"@stdlib/slice-ctor": "^0.1.0",
"@stdlib/slice-multi": "^0.1.0",
Expand Down
183 changes: 3 additions & 180 deletions test/dist/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,190 +21,13 @@
// MODULES //

var tape = require( 'tape' );
var Float64Array = require( '@stdlib/array-float64' );
var zeros = require( '@stdlib/ndarray-zeros' );
var ndarray = require( '@stdlib/ndarray-ctor' );
var offset = require( './../../dist' );
var main = require( './../../dist' );


// TESTS //

tape( 'main export is a function', function test( t ) {
tape( 'main export is defined', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof offset, 'function', 'main export is a function' );
t.end();
});

tape( 'if provided a zero-dimensional ndarray, the function returns 0', function test( t ) {
t.strictEqual( offset( zeros( [] ) ), 0, 'returns expected value' );
t.end();
});

tape( 'the function returns the index offset', function test( t ) {
var expected;
var values;
var n;
var i;

values = [
zeros( [ 3, 3, 3 ] ),
zeros( [ 1, 1 ] ),
zeros( [ 3, 3, 0, 3 ] ),
zeros( [ 1, 2, 3, 4 ] ),
zeros( [ 5 ] ),
ndarray( 'float64', new Float64Array( 100 ), [ 2, 2 ], [ 2, 1 ], 50, 'row-major' ),
ndarray( 'float64', new Float64Array( 100 ), [ 2, 2 ], [ 2, 1 ], 35, 'row-major' ),
ndarray( 'float64', new Float64Array( 100 ), [ 2, 2 ], [ -2, -1 ], 3, 'row-major' )
];

expected = [
0,
0,
0,
0,
0,
50,
35,
3
];

for ( i = 0; i < values.length; i++ ) {
n = offset( values[ i ] );
t.strictEqual( n, expected[ i ], 'returns expected value for shape '+values[ i ].shape.join( 'x' ) );
}
t.end();
});

tape( 'the function accepts minimal ndarray-like objects (shape, strides)', function test( t ) {
var expected;
var values;
var n;
var i;

values = [
{
'shape': [ 3, 3, 3 ],
'strides': [ -9, -3, -1 ]
},
{
'shape': [ 1, 1 ],
'strides': [ 1, 1 ]
},
{
'shape': [ 3, 3, 0, 3 ],
'strides': [ 0, 0, 0, 1 ]
},
{
'shape': [ 1, 2, 3, 4 ],
'strides': [ 24, 12, 4, 1 ]
},
{
'shape': [ 5 ],
'strides': [ -1 ]
},
{
'shape': [],
'strides': [ 0 ]
}
];

expected = [
26,
0,
0,
0,
4,
0
];

for ( i = 0; i < values.length; i++ ) {
n = offset( values[ i ] );
t.strictEqual( n, expected[ i ], 'returns expected value for shape '+values[ i ].shape.join( 'x' ) );
}
t.end();
});

tape( 'the function accepts minimal ndarray-like objects (shape)', function test( t ) {
var expected;
var values;
var n;
var i;

values = [
{
'shape': [ 3, 3, 3 ],
'strides': null
},
{
'shape': [ 1, 1 ]
},
{
'shape': [ 3, 3, 0, 3 ],
'strides': null
},
{
'shape': [ 1, 2, 3, 4 ]
},
{
'shape': [ 5 ],
'strides': null
},
{
'shape': []
}
];

expected = [
0,
0,
0,
0,
0,
0
];

for ( i = 0; i < values.length; i++ ) {
n = offset( values[ i ] );
t.strictEqual( n, expected[ i ], 'returns expected value for shape '+values[ i ].shape.join( 'x' ) );
}
t.end();
});

tape( 'the function accepts minimal ndarray-like objects (offset)', function test( t ) {
var expected;
var values;
var n;
var i;

values = [
{
'offset': 3
},
{
'offset': 1
},
{
'offset': 0
},
{
'offset': 4
},
{
'offset': 5
}
];

expected = [
3,
1,
0,
4,
5
];

for ( i = 0; i < values.length; i++ ) {
n = offset( values[ i ] );
t.strictEqual( n, expected[ i ], 'returns expected value for '+values[ i ] );
}
t.strictEqual( main !== void 0, true, 'main export is defined' );
t.end();
});

0 comments on commit dec062b

Please sign in to comment.