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 Feb 20, 2024
1 parent 8f44f1e commit 664d00f
Show file tree
Hide file tree
Showing 8 changed files with 1,665 additions and 4 deletions.
68 changes: 68 additions & 0 deletions to-fancy/benchmark/benchmark.get.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var isCollection = require( '@stdlib/assert/is-collection' );
var hasProxySupport = require( '@stdlib/assert/has-proxy-support' );
var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive;
var zeroTo = require( './../../zero-to' );
var zeros = require( './../../zeros' );
var filledarray = require( './../../filled' );
var Slice = require( '@stdlib/slice/ctor' );
var pkg = require( './../package.json' ).name;
var array2fancy = require( './../lib' );
Expand Down Expand Up @@ -171,3 +173,69 @@ bench( pkg+'::get,integer_array:len=1', opts, function benchmark( b ) {
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+'::get,mask_array:len=1', opts, function benchmark( b ) {
var values;
var opts;
var x;
var v;
var i;

x = array2fancy( zeros( 100, 'uint8' ) );

opts = {
'persist': true
};
values = [
array2fancy.idx( [ 1 ], opts ),
array2fancy.idx( [ 2 ], opts ),
array2fancy.idx( [ 3 ], opts )
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = x[ values[ i%values.length ] ];
if ( typeof v !== 'object' ) {
b.fail( 'should return an array' );
}
}
b.toc();
if ( !isCollection( v ) ) {
b.fail( 'should return an array' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+'::get,boolean_array:len=1', opts, function benchmark( b ) {
var values;
var opts;
var x;
var v;
var i;

x = array2fancy( filledarray( true, 100, 'generic' ) );

opts = {
'persist': true
};
values = [
array2fancy.idx( [ 1 ], opts ),
array2fancy.idx( [ 2 ], opts ),
array2fancy.idx( [ 3 ], opts )
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = x[ values[ i%values.length ] ];
if ( typeof v !== 'object' ) {
b.fail( 'should return an array' );
}
}
b.toc();
if ( !isCollection( v ) ) {
b.fail( 'should return an array' );
}
b.pass( 'benchmark finished' );
b.end();
});
7 changes: 6 additions & 1 deletion to-fancy/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
configuration as specified by provided options.

A fancy array supports indexing using positive and negative integers (both
numeric literals and strings), Slice instances, and subsequence expressions.
numeric literals and strings), Slice instances, subsequence expressions,
mask arrays, boolean arrays, and integer arrays.

A fancy array supports all properties and methods of the input array, and,
thus, a fancy array can be consumed by any API which supports array-like
Expand Down Expand Up @@ -77,6 +78,8 @@
If an array index is not associated with a provided identifier, the
'get' method should return `null`.

Default: `{{alias:@stdlib/array/index}}`.

Returns
-------
out: Array|TypedArray|Object
Expand Down Expand Up @@ -118,6 +121,8 @@
If an array index is not associated with a provided identifier, the
'get' method should return `null`.

Default: `{{alias:@stdlib/array/index}}`.

Returns
-------
fcn: Function
Expand Down
2 changes: 1 addition & 1 deletion to-fancy/lib/error_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var replace = require( '@stdlib/string/base/replace' );
* @returns {string} updated message
*/
function errMessage( msg ) {
return replace( msg, /^invalid argument/, 'invalid operation' );
return replace( msg, /^invalid arguments?/, 'invalid operation' );
}


Expand Down
4 changes: 2 additions & 2 deletions to-fancy/lib/get_elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// MODULES //

var take = require( './../../take' );
var mskfilter = require( './../../base/mskfilter' );
var mskreject = require( './../../base/mskreject' );
var mskfilter = require( './../../mskfilter' );
var mskreject = require( './../../mskreject' );
var format = require( '@stdlib/string/format' );
var prop2array = require( './prop2array.js' );

Expand Down
Loading

0 comments on commit 664d00f

Please sign in to comment.