From 67eb737e3d214bf6dbc6732103cff23ce051ef62 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Tue, 9 Dec 2025 22:06:34 +0500 Subject: [PATCH 1/8] feat: add blas/ext/base/ndarray/gjoin --- 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 --- --- .../blas/ext/base/ndarray/gjoin/README.md | 122 ++++++++++++++++++ .../base/ndarray/gjoin/benchmark/benchmark.js | 108 ++++++++++++++++ .../blas/ext/base/ndarray/gjoin/docs/repl.txt | 33 +++++ .../base/ndarray/gjoin/docs/types/index.d.ts | 50 +++++++ .../ext/base/ndarray/gjoin/docs/types/test.ts | 64 +++++++++ .../ext/base/ndarray/gjoin/examples/index.js | 40 ++++++ .../blas/ext/base/ndarray/gjoin/lib/index.js | 49 +++++++ .../blas/ext/base/ndarray/gjoin/lib/main.js | 62 +++++++++ .../blas/ext/base/ndarray/gjoin/package.json | 63 +++++++++ .../blas/ext/base/ndarray/gjoin/test/test.js | 80 ++++++++++++ 10 files changed, 671 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/README.md new file mode 100644 index 000000000000..ddfd8ac65469 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/README.md @@ -0,0 +1,122 @@ + + +# gjoin + +> Return a string created by joining one-dimensional ndarray elements using a specified separator. + +
+ +
+ + + +
+ +## Usage + +```javascript +var gjoin = require( '@stdlib/blas/ext/base/ndarray/gjoin' ); +``` + +#### gjoin( arrays ) + +Returns a string created by joining one-dimensional ndarray elements using a specified separator. + +```javascript +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); + +var xbuf = [ 1.0, 3.0, 4.0, 2.0 ]; +var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + +var separator = scalar2ndarray( ',', { + 'dtype': 'generic' +}); + +var out = gjoin( [ x, separator ] ); +// returns '1,3,4,2' +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the separator. + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var gjoin = require( '@stdlib/blas/ext/base/ndarray/gjoin' ); + +var xbuf = discreteUniform( 10, -100, 100, { + 'dtype': 'generic' +}); +var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var separator = scalar2ndarray( ',', { + 'dtype': 'generic' +}); +console.log( 'Separator:', ndarraylike2scalar( separator ) ); + +var out = gjoin( [ x, separator ] ); +console.log( out ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js new file mode 100644 index 000000000000..333786cae993 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var pkg = require( './../package.json' ).name; +var gjoin = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var separator; + var xbuf; + var x; + + xbuf = uniform( len, 0.0, 100.0, options ); + x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' ); + + separator = scalar2ndarray( ',', { + 'dtype': options.dtype + }); + + return benchmark; + + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = gjoin( [ x, separator ] ); + if ( out !== out ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/repl.txt new file mode 100644 index 000000000000..84bca0676e04 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/repl.txt @@ -0,0 +1,33 @@ + +{{alias}}( arrays ) + Returns a string created by joining one-dimensional ndarray elements using a + specified separator. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the separator. + + Returns + ------- + out: string + Joined string. + + Examples + -------- + > var xbuf = [ 1.0, 2.0, 3.0 ]; + > var dt = 'generic'; + > var sh = [ xbuf.length ]; + > var sx = [ 1 ]; + > var ox = 0; + > var ord = 'row-major'; + > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); + > var v = {{alias:@stdlib/ndarray/from-scalar}}( ',', { 'dtype': dt } ); + > {{alias}}( [ x, v ] ) + '1,2,3' + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts new file mode 100644 index 000000000000..c1e452553de7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts @@ -0,0 +1,50 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { typedndarray } from '@stdlib/types/ndarray'; + +/** +* Returns a string created by joining one-dimensional ndarray elements using a specified separator. +* +* @param arrays - array-like object containing a one-dimensional input ndarray, a zero-dimensional ndarray containing the separator +* @returns joined string +* +* @example +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var xbuf = [ 1.0, 3.0, 4.0, 2.0 ]; +* var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var separator = scalar2ndarray( ',', { +* 'dtype': 'generic' +* }); +* +* var v = gjoin( [ x, separator ] ); +* // returns '1,3,4,2' +*/ +declare function gjoin( arrays: [ typedndarray, typedndarray ] ): string; + + +// EXPORTS // + +export = gjoin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/test.ts new file mode 100644 index 000000000000..3020843a6a21 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/test.ts @@ -0,0 +1,64 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import gjoin = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const x = zeros( [ 10 ], { + 'dtype': 'generic' + }); + const separator = scalar2ndarray( ',', { + 'dtype': 'generic' + }); + + gjoin( [ x, separator ] ); // $ExpectType string +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + gjoin( '10' ); // $ExpectError + gjoin( 10 ); // $ExpectError + gjoin( true ); // $ExpectError + gjoin( false ); // $ExpectError + gjoin( null ); // $ExpectError + gjoin( undefined ); // $ExpectError + gjoin( [] ); // $ExpectError + gjoin( {} ); // $ExpectError + gjoin( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 10 ], { + 'dtype': 'generic' + }); + const separator = scalar2ndarray( 0.0, { + 'dtype': 'generic' + }); + + gjoin(); // $ExpectError + gjoin( [ x, separator ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js new file mode 100644 index 000000000000..199df199132c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var gjoin = require( './../lib' ); + +var xbuf = discreteUniform( 10, -100, 100, { + 'dtype': 'generic' +}); +var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var separator = scalar2ndarray( ',', { + 'dtype': 'generic' +}); +console.log( 'Separator:', ndarraylike2scalar( separator ) ); + +var out = gjoin( [ x, gjoin ] ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/index.js new file mode 100644 index 000000000000..25b5a84622d0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/index.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Return a string created by joining one-dimensional ndarray elements using a specified separator. +* +* @module @stdlib/blas/ext/base/ndarray/gjoin +* +* @example +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var gjoin = require( '@stdlib/blas/ext/base/ndarray/gjoin' ); +* +* var xbuf = [ 1.0, 3.0, 4.0, 2.0 ]; +* var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var separator = scalar2ndarray( ',', { +* 'dtype': 'generic' +* }); +* +* var v = gjoin( [ x, separator ] ); +* // returns '1,3,4,2' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js new file mode 100644 index 000000000000..0b3f92a48d80 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var strided = require( '@stdlib/blas/ext/base/gjoin' ).ndarray; +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); + + +// MAIN // + +/** +* Returns a string created by joining one-dimensional ndarray elements using a specified separator. +* +* @param {ArrayLikeObject} arrays - array-like object containing a one-dimensional input ndarray, a zero-dimensional ndarray containing the separator +* @returns {string} joined string +* +* @example +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var xbuf = [ 1.0, 3.0, 4.0, 2.0 ]; +* var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var separator = scalar2ndarray( ',', { +* 'dtype': 'generic' +* }); +* +* var v = gjoin( [ x, separator ] ); +* // returns '1,3,4,2' +*/ +function gjoin( arrays ) { + var x = arrays[ 0 ]; + var s = ndarraylike2scalar( arrays[ 1 ] ); + return strided( numelDimension( x, 0 ), s, getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = gjoin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/package.json new file mode 100644 index 000000000000..dac9901376f1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/package.json @@ -0,0 +1,63 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/gjoin", + "version": "0.0.0", + "description": "Return a string created by joining one-dimensional ndarray elements using a specified separator.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "array", + "join", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/test/test.js new file mode 100644 index 000000000000..93f0b148caa0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/test/test.js @@ -0,0 +1,80 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 tape = require( 'tape' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var gjoin = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'generic', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gjoin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a string created by joining one-dimensional ndarray elements using a specified separator', function test( t ) { + var separator; + var actual; + var x; + + x = vector( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ], 6, 1, 0 ); + + separator = scalar2ndarray( ',', { + 'dtype': 'generic' + }); + actual = gjoin( [ x, separator ] ); + t.strictEqual( actual, '1,1,2,2,3,3', 'returns expected value' ); + + separator = scalar2ndarray( '|', { + 'dtype': 'generic' + }); + actual = gjoin( [ x, separator ] ); + t.strictEqual( actual, '1|1|2|2|3|3', 'returns expected value' ); + + separator = scalar2ndarray( '>', { + 'dtype': 'generic' + }); + actual = gjoin( [ x, separator ] ); + t.strictEqual( actual, '1>1>2>2>3>3', 'returns expected value' ); + + t.end(); +}); From b55b1acd7e46f584e95a521a08dba6e7c81217ed Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 9 Dec 2025 22:37:20 +0500 Subject: [PATCH 2/8] fix: apply suggestions from code review Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> --- .../@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js index 199df199132c..49fcb10c8783 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js @@ -36,5 +36,5 @@ var separator = scalar2ndarray( ',', { }); console.log( 'Separator:', ndarraylike2scalar( separator ) ); -var out = gjoin( [ x, gjoin ] ); +var out = gjoin( [ x, separator ] ); console.log( out ); From c7de42f76ba383b208fc0de03929b7fac06de0b6 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 9 Dec 2025 18:22:38 -0800 Subject: [PATCH 3/8] bench: simplify expression Signed-off-by: Athan --- .../blas/ext/base/ndarray/gjoin/benchmark/benchmark.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js index 333786cae993..f86b8e7ffe44 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js @@ -54,9 +54,7 @@ function createBenchmark( len ) { xbuf = uniform( len, 0.0, 100.0, options ); x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' ); - separator = scalar2ndarray( ',', { - 'dtype': options.dtype - }); + separator = scalar2ndarray( ',', options ); return benchmark; From 2c5ddbbec6687e5ebbbcc6c56f35456dbc69c1da Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 9 Dec 2025 18:23:33 -0800 Subject: [PATCH 4/8] bench: explicitly specify separator dtype Signed-off-by: Athan --- .../blas/ext/base/ndarray/gjoin/benchmark/benchmark.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js index f86b8e7ffe44..9a27c7b0fec2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/benchmark/benchmark.js @@ -54,7 +54,9 @@ function createBenchmark( len ) { xbuf = uniform( len, 0.0, 100.0, options ); x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' ); - separator = scalar2ndarray( ',', options ); + separator = scalar2ndarray( ',', { + 'dtype': 'generic' + }); return benchmark; From c4ee1a4120d6c99a67d03634faf41541cb28c95d Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 9 Dec 2025 18:24:46 -0800 Subject: [PATCH 5/8] docs: update copy Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts index c1e452553de7..6a312439b9a4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts @@ -25,7 +25,7 @@ import { typedndarray } from '@stdlib/types/ndarray'; /** * Returns a string created by joining one-dimensional ndarray elements using a specified separator. * -* @param arrays - array-like object containing a one-dimensional input ndarray, a zero-dimensional ndarray containing the separator +* @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a separator * @returns joined string * * @example From 5fccca1aa7cd442414b9491e761c8908d8e7020d Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 9 Dec 2025 18:26:19 -0800 Subject: [PATCH 6/8] feat: allow separator array to have different dtype Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts index 6a312439b9a4..60ef701ecef9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/docs/types/index.d.ts @@ -42,7 +42,7 @@ import { typedndarray } from '@stdlib/types/ndarray'; * var v = gjoin( [ x, separator ] ); * // returns '1,3,4,2' */ -declare function gjoin( arrays: [ typedndarray, typedndarray ] ): string; +declare function gjoin( arrays: [ typedndarray, typedndarray ] ): string; // EXPORTS // From 07344679987f11ed80261e7e1a019a9b8fb6fa16 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 9 Dec 2025 18:27:19 -0800 Subject: [PATCH 7/8] style: add whitespace Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js index 49fcb10c8783..eb7f035fa292 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/examples/index.js @@ -34,7 +34,7 @@ console.log( ndarray2array( x ) ); var separator = scalar2ndarray( ',', { 'dtype': 'generic' }); -console.log( 'Separator:', ndarraylike2scalar( separator ) ); +console.log( 'Separator: ', ndarraylike2scalar( separator ) ); var out = gjoin( [ x, separator ] ); console.log( out ); From 353ed812205a6c97bf1ab0f468ac966b32408082 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 9 Dec 2025 18:28:19 -0800 Subject: [PATCH 8/8] docs: fix desc Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js index 0b3f92a48d80..af26cc78a4e3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gjoin/lib/main.js @@ -33,7 +33,7 @@ var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); /** * Returns a string created by joining one-dimensional ndarray elements using a specified separator. * -* @param {ArrayLikeObject} arrays - array-like object containing a one-dimensional input ndarray, a zero-dimensional ndarray containing the separator +* @param {ArrayLikeObject} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a separator * @returns {string} joined string * * @example