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 Sep 27, 2023
1 parent 3a04a99 commit b87ab27
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/ind/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function ind( idx, max, mode ) {
return wrapIndex( idx, max );
}
if ( idx < 0 || idx > max ) {
throw new RangeError( format( 'invalid argument. Index must be on the interval: [0, %f]. Value: `%f`.', max, idx ) );
throw new RangeError( format( 'invalid argument. Index must be on the interval: [0, %d]. Value: `%d`.', max, idx ) );
}
return idx;
}
Expand Down
47 changes: 47 additions & 0 deletions base/slice/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ tape( 'the function returns a view of a provided input array (ndims=1)', functio

t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
t.strictEqual( actual.length, 6, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.data, x.data, 'returns expected value' );

Expand All @@ -319,12 +320,58 @@ tape( 'the function returns a view of a provided input array (ndims=1)', functio

t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
t.strictEqual( actual.length, 3, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.data, x.data, 'returns expected value' );

expected = [ 14, 10, 6 ];
for ( i = 0; i < expected.length; i++ ) {
t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
}

// Reverse order and skip every other element, starting from second-to-last element:
s = new MultiSlice( new Slice( 4, null, -2 ) );
actual = slice( x, s, true );

t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
t.strictEqual( actual.length, 3, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.data, x.data, 'returns expected value' );

expected = [ 12, 8, 4 ];
for ( i = 0; i < expected.length; i++ ) {
t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
}

// Skip every three elements, starting from second element:
s = new MultiSlice( new Slice( 1, null, 3 ) );
actual = slice( x, s, true );

t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
t.strictEqual( actual.length, 2, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.data, x.data, 'returns expected value' );

expected = [ 6, 12 ];
for ( i = 0; i < expected.length; i++ ) {
t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
}

// Get a sub-array:
s = new MultiSlice( new Slice( 4, 1, -1 ) );
actual = slice( x, s, true );

t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
t.strictEqual( actual.length, 3, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.data, x.data, 'returns expected value' );

expected = [ 12, 10, 8 ];
for ( i = 0; i < expected.length; i++ ) {
t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
}
t.end();
});
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit b87ab27

Please sign in to comment.