Skip to content

Commit 1603708

Browse files
committed
Auto-generated commit
1 parent a8df57e commit 1603708

3 files changed

Lines changed: 63 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,9 @@ A total of 44 issues were closed in this release:
774774

775775
<details>
776776

777+
- [`f7bad8d`](https://github.com/stdlib-js/stdlib/commit/f7bad8d512bc207e4e25ed18a15b43a6e98540aa) - **test:** update test _(by Athan Reines)_
778+
- [`663e715`](https://github.com/stdlib-js/stdlib/commit/663e715df67c0008b1d807e55a4555e54bf8d5ef) - **test:** update test _(by Athan Reines)_
779+
- [`93406df`](https://github.com/stdlib-js/stdlib/commit/93406df6ffbb6494062605352b7df9c05694c81d) - **test:** add missing tests _(by Athan Reines)_
777780
- [`f91aca6`](https://github.com/stdlib-js/stdlib/commit/f91aca6650536cb46c7b4c41bd05a2a37e0fe475) - **feat:** add `maybeBroadcastArrayExceptDimensions` to namespace _(by Athan Reines)_
778781
- [`5324e96`](https://github.com/stdlib-js/stdlib/commit/5324e9618a4b8688b4792ccceb146b348d9a9f2f) - **feat:** add `ndarray/base/maybe-broadcast-array-except-dimensions` [(#10413)](https://github.com/stdlib-js/stdlib/pull/10413) _(by Muhammad Haris, Athan Reines)_
779782
- [`f10a6aa`](https://github.com/stdlib-js/stdlib/commit/f10a6aaf98c37bb630ac75e1a50dd0bd4a0eb417) - **fix:** ensure unique indices _(by Athan Reines)_

base/broadcast-array-except-dimensions/test/test.js

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,58 @@ tape( 'the function throws an error if provided a desired shape and an input arr
123123
}
124124
});
125125

126+
tape( 'the function throws an error if provided duplicate dimensions', function test( t ) {
127+
var values;
128+
var x;
129+
var i;
130+
131+
x = array({
132+
'shape': [ 2, 10, 10 ]
133+
});
134+
135+
values = [
136+
[ -3, -3 ],
137+
[ -2, -2 ],
138+
[ -1, -1 ]
139+
];
140+
for ( i = 0; i < values.length; i++ ) {
141+
t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ['+values[ i ].join( ',')+']' );
142+
}
143+
t.end();
144+
145+
function badValue( value ) {
146+
return function badValue() {
147+
broadcastArrayExceptDimensions( x, [ 2, 10, 10 ], value );
148+
};
149+
}
150+
});
151+
152+
tape( 'the function throws an error if provided out-of-bounds dimensions', function test( t ) {
153+
var values;
154+
var x;
155+
var i;
156+
157+
x = array({
158+
'shape': [ 2, 10, 10 ]
159+
});
160+
161+
values = [
162+
[ -4 ],
163+
[ -5 ],
164+
[ -6 ]
165+
];
166+
for ( i = 0; i < values.length; i++ ) {
167+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ['+values[ i ].join( ',')+']' );
168+
}
169+
t.end();
170+
171+
function badValue( value ) {
172+
return function badValue() {
173+
broadcastArrayExceptDimensions( x, [ 2, 10, 10 ], value );
174+
};
175+
}
176+
});
177+
126178
tape( 'the function returns a "base" ndarray instance', function test( t ) {
127179
var x;
128180
var y;
@@ -405,10 +457,10 @@ tape( 'the function broadcasts an input array (singleton dimension)', function t
405457
var v;
406458
var i;
407459

408-
data = [ 1, 2 ];
460+
data = [ 1 ];
409461
x = array( data, {
410462
'dtype': 'generic',
411-
'shape': [ 1, 2 ],
463+
'shape': [ 1, 1 ],
412464
'order': 'row-major'
413465
});
414466

@@ -423,13 +475,13 @@ tape( 'the function broadcasts an input array (singleton dimension)', function t
423475
t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
424476

425477
v = y.get( i, 0, 1 );
426-
t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
478+
t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,1)' );
427479

428480
v = y.get( i, 0, 0 );
429481
t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
430482

431483
v = y.get( i, 0, 1 );
432-
t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
484+
t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,1)' );
433485
}
434486
t.end();
435487
});

base/maybe-broadcast-array-except-dimensions/test/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,10 @@ tape( 'the function broadcasts an input array (singleton dimension)', function t
460460
var v;
461461
var i;
462462

463-
data = [ 1, 2 ];
463+
data = [ 1 ];
464464
x = array( data, {
465465
'dtype': 'generic',
466-
'shape': [ 1, 2 ],
466+
'shape': [ 1, 1 ],
467467
'order': 'row-major'
468468
});
469469

@@ -478,13 +478,13 @@ tape( 'the function broadcasts an input array (singleton dimension)', function t
478478
t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
479479

480480
v = y.get( i, 0, 1 );
481-
t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
481+
t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,1)' );
482482

483483
v = y.get( i, 0, 0 );
484484
t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
485485

486486
v = y.get( i, 0, 1 );
487-
t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
487+
t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,1)' );
488488
}
489489
t.end();
490490
});

0 commit comments

Comments
 (0)