Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing ndarray test fixture #1054

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions lib/node_modules/@stdlib/ndarray/dispatch-by/test/fixtures/fill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var ind2sub = require( '@stdlib/ndarray/ind2sub' );
var numel = require( '@stdlib/ndarray/base/numel' );


// MAIN //

/**
* Return an ndarray function which fills one or more ndarrays.
*
* @private
* @param {*} value - fill value
* @returns {Function} ndarray function
*/
function fill( value ) {
return ndarrayFcn;

/**
* ndarray function.
*
* @private
* @param {Array<ndarrayLike>} arrays - ndarrays
*/
function ndarrayFcn( arrays ) {
var opts;
var sub;
var arr;
var sh;
var M;
var N;
var i;
var j;

sh = arrays[ 0 ].shape;
N = numel( sh );
M = arrays.length;
opts = {
'order': ''
};
for ( j = 0; j < M; j++ ) {
arr = arrays[ j ];
opts.order = arrays[ j ].order;
for ( i = 0; i < N; i++ ) {
sub = ind2sub( sh, i, opts );
sub.push( value );
arr.set.apply( arr, sub );
}
}
}
}


// EXPORTS //

module.exports = fill;
Loading