Skip to content

Commit 028683a

Browse files
committed
refactor: apply suggestions from code review
--- 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: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - 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 ---
1 parent a4ab7d6 commit 028683a

File tree

6 files changed

+9
-454
lines changed

6 files changed

+9
-454
lines changed

lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ limitations under the License.
4242
var broadcastArrayExceptDimensions = require( '@stdlib/ndarray/base/broadcast-array-except-dimensions' );
4343
```
4444

45-
#### broadcastArrayExceptDimensions( arr, shape\[, dims] )
45+
#### broadcastArrayExceptDimensions( arr, shape, dims )
4646

4747
Broadcast an input [ndarray][@stdlib/ndarray/base/ctor] to a target shape keeping the specified dimensions unchanged.
4848

@@ -54,7 +54,7 @@ var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
5454
// returns <ndarray>
5555

5656
// Perform broadcasting:
57-
var y = broadcastArrayExceptDimensions( x, [ 3, 2, 2 ] );
57+
var y = broadcastArrayExceptDimensions( x, [ 3, 2, 2 ], [ -1 ] );
5858
// returns <ndarray>
5959

6060
var ysh = y.shape;
@@ -65,24 +65,7 @@ The function accepts the following arguments:
6565

6666
- **arr**: input ndarray.
6767
- **shape**: target shape.
68-
- **dims**: list of dimensions which are exculded from broadcasting. Default: `[ -1 ]` (_optional_).
69-
70-
To exclude specific dimensions from broadcasting, provide a `dims` parameter.
71-
72-
```javascript
73-
var array = require( '@stdlib/ndarray/array' );
74-
75-
// Create a 2x2 ndarray:
76-
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
77-
// returns <ndarray>
78-
79-
// Perform broadcasting:
80-
var y = broadcastArrayExceptDimensions( x, [ 3, 2, 2 ], [ -2 ] );
81-
// returns <ndarray>
82-
83-
var ysh = y.shape;
84-
// returns [ 3, 2, 2 ]
85-
```
68+
- **dims**: list of dimensions which are exculded from broadcasting.
8669

8770
</section>
8871

lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/benchmark/benchmark.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bench( pkg+'::base_ndarray,2d', function benchmark( b ) {
5959

6060
b.tic();
6161
for ( i = 0; i < b.iterations; i++ ) {
62-
out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ] );
62+
out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ], [ -1 ] );
6363
if ( typeof out !== 'object' ) {
6464
b.fail( 'should return an object' );
6565
}
@@ -100,7 +100,7 @@ bench( pkg+'::ndarray,2d', function benchmark( b ) {
100100

101101
b.tic();
102102
for ( i = 0; i < b.iterations; i++ ) {
103-
out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ] );
103+
out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ], [ -1 ] );
104104
if ( typeof out !== 'object' ) {
105105
b.fail( 'should return an object' );
106106
}
@@ -147,7 +147,7 @@ bench( pkg+'::ndarray_like,2d', function benchmark( b ) {
147147

148148
b.tic();
149149
for ( i = 0; i < b.iterations; i++ ) {
150-
out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ] );
150+
out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ], [ -2 ] );
151151
if ( typeof out !== 'object' ) {
152152
b.fail( 'should return an object' );
153153
}

lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/repl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{alias}}( arr, shape[, dims] )
2+
{{alias}}( arr, shape, dims )
33
Broadcasts an input ndarray to a target shape keeping the specified
44
dimensions unchanged.
55

@@ -23,7 +23,7 @@
2323
shape: ArrayLikeObject
2424
Desired shape.
2525

26-
dims: Array<integer> (optional)
26+
dims: Array<integer>
2727
List of dimensions to exclude from broadcasting.
2828

2929
Returns

lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import { ndarray } from '@stdlib/types/ndarray';
7575
* v = y.get( 1, 0, 2 );
7676
* // returns 3
7777
*/
78-
declare function broadcastArrayExceptDimensions( arr: ndarray, shape: ArrayLike<number>, dims?: ArrayLike<number> ): ndarray;
78+
declare function broadcastArrayExceptDimensions( arr: ndarray, shape: ArrayLike<number>, dims: ArrayLike<number> ): ndarray;
7979

8080

8181
// EXPORTS //

lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/types/test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,11 @@ function array(): ndarray {
5555
{
5656
const x = array();
5757

58-
broadcastArrayExceptDimensions( x, [ 2, 2, 2 ] ); // $ExpectType ndarray
5958
broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], [ -2 ] ); // $ExpectType ndarray
6059
}
6160

6261
// The compiler throws an error if the function is not provided a first argument which is an ndarray...
6362
{
64-
broadcastArrayExceptDimensions( '5', [ 2, 2, 2 ] ); // $ExpectError
65-
broadcastArrayExceptDimensions( 5, [ 2, 2, 2 ] ); // $ExpectError
66-
broadcastArrayExceptDimensions( true, [ 2, 2, 2 ] ); // $ExpectError
67-
broadcastArrayExceptDimensions( false, [ 2, 2, 2 ] ); // $ExpectError
68-
broadcastArrayExceptDimensions( null, [ 2, 2, 2 ] ); // $ExpectError
69-
broadcastArrayExceptDimensions( {}, [ 2, 2, 2 ] ); // $ExpectError
70-
broadcastArrayExceptDimensions( [ '5' ], [ 2, 2, 2 ] ); // $ExpectError
71-
broadcastArrayExceptDimensions( ( x: number ): number => x, [ 2, 2, 2 ] ); // $ExpectError
72-
7363
broadcastArrayExceptDimensions( '5', [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
7464
broadcastArrayExceptDimensions( 5, [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
7565
broadcastArrayExceptDimensions( true, [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
@@ -84,15 +74,6 @@ function array(): ndarray {
8474
{
8575
const x = array();
8676

87-
broadcastArrayExceptDimensions( x, '5' ); // $ExpectError
88-
broadcastArrayExceptDimensions( x, 5 ); // $ExpectError
89-
broadcastArrayExceptDimensions( x, true ); // $ExpectError
90-
broadcastArrayExceptDimensions( x, false ); // $ExpectError
91-
broadcastArrayExceptDimensions( x, null ); // $ExpectError
92-
broadcastArrayExceptDimensions( x, {} ); // $ExpectError
93-
broadcastArrayExceptDimensions( x, [ '5' ] ); // $ExpectError
94-
broadcastArrayExceptDimensions( x, ( x: number ): number => x ); // $ExpectError
95-
9677
broadcastArrayExceptDimensions( x, '5', [ -2 ] ); // $ExpectError
9778
broadcastArrayExceptDimensions( x, 5, [ -2 ] ); // $ExpectError
9879
broadcastArrayExceptDimensions( x, true, [ -2 ] ); // $ExpectError

0 commit comments

Comments
 (0)