From 3814a2d5c2dacbb59f914667a0e27716a1f50115 Mon Sep 17 00:00:00 2001 From: 0PrashantYadav0 Date: Thu, 10 Sep 2026 19:49:55 +0530 Subject: [PATCH] fix: update comments to clarify broadcasting requirements for ndarray inputs --- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/circshift/lib/main.js | 11 ++++++----- lib/node_modules/@stdlib/blas/ext/sort/lib/main.js | 11 +++++++---- lib/node_modules/@stdlib/blas/ext/sorthp/lib/main.js | 11 +++++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/circshift/lib/main.js b/lib/node_modules/@stdlib/blas/ext/circshift/lib/main.js index c83f975c12c5..5d8e897b39be 100644 --- a/lib/node_modules/@stdlib/blas/ext/circshift/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/circshift/lib/main.js @@ -85,8 +85,8 @@ function circshift( x, k ) { } // Case: circshift( x, k_ndarray ) if ( isndarrayLike( k ) ) { - // As the operation is performed across all dimensions, `k` is assumed to be a zero-dimensional ndarray... - return base( x, k ); + // As the operation is performed across all dimensions, `k` must be broadcast-compatible with a zero-dimensional ndarray... + return base( x, maybeBroadcastArray( k, [] ) ); } throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray or an integer. Value: `%s`.', k ) ); } @@ -104,12 +104,13 @@ function circshift( x, k ) { } // Case: circshift( x, k_ndarray, opts ) else if ( isndarrayLike( k ) ) { - // When not provided `dims`, the operation is performed across all dimensions and `k` is assumed to be a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `k` to match the shape of the non-core dimensions... + // When not provided `dims`, the operation is performed across all dimensions and `k` must be broadcast-compatible with a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `k` to match the shape of the non-core dimensions... if ( hasOwnProp( opts, 'dims' ) ) { - ka = maybeBroadcastArray( k, nonCoreShape( getShape( x ), opts.dims ) ); // eslint-disable-line max-len + sh = nonCoreShape( getShape( x ), opts.dims ); } else { - ka = k; + sh = []; } + ka = maybeBroadcastArray( k, sh ); } else { throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray or an integer. Value: `%s`.', k ) ); } diff --git a/lib/node_modules/@stdlib/blas/ext/sort/lib/main.js b/lib/node_modules/@stdlib/blas/ext/sort/lib/main.js index e63d1b1a31d7..0c8d9f4a04cc 100644 --- a/lib/node_modules/@stdlib/blas/ext/sort/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/sort/lib/main.js @@ -176,8 +176,8 @@ function sort( x ) { } // Case: sort( x, sortOrder_ndarray ) if ( isndarrayLike( o ) ) { - // As the operation is performed across all dimensions, `o` is assumed to be a zero-dimensional ndarray... - return base( x, o ); + // As the operation is performed across all dimensions, `o` must be broadcast-compatible with a zero-dimensional ndarray... + return base( x, maybeBroadcastArray( o, [] ) ); } // Case: sort( x, opts ) opts = o; @@ -201,10 +201,13 @@ function sort( x ) { } // Case: sort( x, sortOrder_ndarray, opts ) else if ( isndarrayLike( o ) ) { - // When not provided `dims`, the operation is performed across all dimensions and `o` is assumed to be a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `o` to match the shape of the non-core dimensions... + // When not provided `dims`, the operation is performed across all dimensions and `o` must be broadcast-compatible with a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `o` to match the shape of the non-core dimensions... if ( hasOwnProp( opts, 'dims' ) ) { - o = maybeBroadcastArray( o, nonCoreShape( getShape( x ), opts.dims ) ); + sh = nonCoreShape( getShape( x ), opts.dims ); + } else { + sh = []; } + o = maybeBroadcastArray( o, sh ); } else { throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray, a numeric scalar value, or a supported string. Value: `%s`.', o ) ); } diff --git a/lib/node_modules/@stdlib/blas/ext/sorthp/lib/main.js b/lib/node_modules/@stdlib/blas/ext/sorthp/lib/main.js index fb9353958dc3..c12cb11e96d8 100644 --- a/lib/node_modules/@stdlib/blas/ext/sorthp/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/sorthp/lib/main.js @@ -176,8 +176,8 @@ function sorthp( x ) { } // Case: sorthp( x, sortOrder_ndarray ) if ( isndarrayLike( o ) ) { - // As the operation is performed across all dimensions, `o` is assumed to be a zero-dimensional ndarray... - return base( x, o ); + // As the operation is performed across all dimensions, `o` must be broadcast-compatible with a zero-dimensional ndarray... + return base( x, maybeBroadcastArray( o, [] ) ); } // Case: sorthp( x, opts ) opts = o; @@ -201,10 +201,13 @@ function sorthp( x ) { } // Case: sorthp( x, sortOrder_ndarray, opts ) else if ( isndarrayLike( o ) ) { - // When not provided `dims`, the operation is performed across all dimensions and `o` is assumed to be a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `o` to match the shape of the non-core dimensions... + // When not provided `dims`, the operation is performed across all dimensions and `o` must be broadcast-compatible with a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `o` to match the shape of the non-core dimensions... if ( hasOwnProp( opts, 'dims' ) ) { - o = maybeBroadcastArray( o, nonCoreShape( getShape( x ), opts.dims ) ); + sh = nonCoreShape( getShape( x ), opts.dims ); + } else { + sh = []; } + o = maybeBroadcastArray( o, sh ); } else { throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray, a numeric scalar value, or a supported string. Value: `%s`.', o ) ); }