Skip to content

Commit ff178b2

Browse files
committed
Auto-generated commit
1 parent fa83818 commit ff178b2

3 files changed

Lines changed: 101 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-03-27)
7+
## Unreleased (2025-03-30)
88

99
<section class="packages">
1010

@@ -849,6 +849,7 @@ This release closes the following issue:
849849

850850
##### Bug Fixes
851851

852+
- [`7378f4d`](https://github.com/stdlib-js/stdlib/commit/7378f4db96fc059523a6f181388aa8f4fa202675) - ensure support when providing no dimensions to reduce
852853
- [`91778b7`](https://github.com/stdlib-js/stdlib/commit/91778b7ca6ae2c6ee0c6017687426c3952d90098) - handle scenario where a core dimension is zero
853854

854855
</section>
@@ -1249,6 +1250,8 @@ A total of 7 people contributed to this release. Thank you to the following cont
12491250

12501251
<details>
12511252

1253+
- [`7378f4d`](https://github.com/stdlib-js/stdlib/commit/7378f4db96fc059523a6f181388aa8f4fa202675) - **fix:** ensure support when providing no dimensions to reduce _(by Athan Reines)_
1254+
- [`abbc923`](https://github.com/stdlib-js/stdlib/commit/abbc923faa3036bb6b2bce8446a56926ef26163d) - **docs:** add example _(by Athan Reines)_
12521255
- [`91778b7`](https://github.com/stdlib-js/stdlib/commit/91778b7ca6ae2c6ee0c6017687426c3952d90098) - **fix:** handle scenario where a core dimension is zero _(by Athan Reines)_
12531256
- [`9cb2473`](https://github.com/stdlib-js/stdlib/commit/9cb247321b8b2285713404fc4e43d43630163097) - **chore:** update directory list _(by Athan Reines)_
12541257
- [`0fc4015`](https://github.com/stdlib-js/stdlib/commit/0fc401573e94e99adbd3c31d7067c28ee2d270a1) - **docs:** add README and repl help _(by Athan Reines)_

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Rutam Kathale <138517416+performant23@users.noreply.github.com>
130130
Ruthwik Chikoti <145591715+ruthwikchikoti@users.noreply.github.com>
131131
Ryan Seal <splrk@users.noreply.github.com>
132132
Rylan Yang <137365285+rylany27@users.noreply.github.com>
133+
SAHIL KUMAR <168997976+sahilk45@users.noreply.github.com>
133134
SHIVAM YADAV <120725381+Shivam-1827@users.noreply.github.com>
134135
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
135136
Sanchay Ketan Sinha <122982233+satansin123@users.noreply.github.com>

base/unary-reduce-subarray/lib/main.js

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,101 @@ var MAX_DIMS = UNARY.length - 1;
158158
*
159159
* var arr = ndarray2array( y.data, y.shape, y.strides, y.offset, y.order );
160160
* // returns [ [ true, false, true ] ]
161+
*
162+
* @example
163+
* var Float64Array = require( '@stdlib/array/float64' );
164+
* var ndarray2array = require( '@stdlib/ndarray/base/to-array' );
165+
* var every = require( '@stdlib/ndarray/base/every' );
166+
*
167+
* // Create data buffers:
168+
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
169+
* var ybuf = [ false ];
170+
*
171+
* // Define the array shapes:
172+
* var xsh = [ 1, 3, 2, 2 ];
173+
* var ysh = [];
174+
*
175+
* // Define the array strides:
176+
* var sx = [ 12, 4, 2, 1 ];
177+
* var sy = [ 0 ];
178+
*
179+
* // Define the index offsets:
180+
* var ox = 0;
181+
* var oy = 0;
182+
*
183+
* // Create an input ndarray-like object:
184+
* var x = {
185+
* 'dtype': 'float64',
186+
* 'data': xbuf,
187+
* 'shape': xsh,
188+
* 'strides': sx,
189+
* 'offset': ox,
190+
* 'order': 'row-major'
191+
* };
192+
*
193+
* // Create an output ndarray-like object:
194+
* var y = {
195+
* 'dtype': 'generic',
196+
* 'data': ybuf,
197+
* 'shape': ysh,
198+
* 'strides': sy,
199+
* 'offset': oy,
200+
* 'order': 'row-major'
201+
* };
202+
*
203+
* // Perform a reduction:
204+
* unaryReduceSubarray( every, [ x, y ], [ 0, 1, 2, 3 ] );
205+
*
206+
* var v = y.data;
207+
* // returns [ true ]
208+
*
209+
* @example
210+
* var Float64Array = require( '@stdlib/array/float64' );
211+
* var filled = require( '@stdlib/array/base/filled' );
212+
* var ndarray2array = require( '@stdlib/ndarray/base/to-array' );
213+
* var every = require( '@stdlib/ndarray/base/every' );
214+
*
215+
* // Create data buffers:
216+
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
217+
* var ybuf = filled( false, 12 );
218+
*
219+
* // Define the array shapes:
220+
* var xsh = [ 3, 2, 2 ];
221+
* var ysh = [ 3, 2, 2 ];
222+
*
223+
* // Define the array strides:
224+
* var sx = [ 4, 2, 1 ];
225+
* var sy = [ 4, 2, 1 ];
226+
*
227+
* // Define the index offsets:
228+
* var ox = 0;
229+
* var oy = 0;
230+
*
231+
* // Create an input ndarray-like object:
232+
* var x = {
233+
* 'dtype': 'float64',
234+
* 'data': xbuf,
235+
* 'shape': xsh,
236+
* 'strides': sx,
237+
* 'offset': ox,
238+
* 'order': 'row-major'
239+
* };
240+
*
241+
* // Create an output ndarray-like object:
242+
* var y = {
243+
* 'dtype': 'generic',
244+
* 'data': ybuf,
245+
* 'shape': ysh,
246+
* 'strides': sy,
247+
* 'offset': oy,
248+
* 'order': 'row-major'
249+
* };
250+
*
251+
* // Perform a reduction:
252+
* unaryReduceSubarray( every, [ x, y ], [] );
253+
*
254+
* var arr = ndarray2array( y.data, y.shape, y.strides, y.offset, y.order );
255+
* // returns [ [ [ true, true ], [ true, true ] ], [ [ true, false ], [ true, true ] ], [ [ true, true ], [ true, true ] ] ]
161256
*/
162257
function unaryReduceSubarray( fcn, arrays, dims, options ) { // eslint-disable-line max-statements
163258
var views;
@@ -263,7 +358,7 @@ function unaryReduceSubarray( fcn, arrays, dims, options ) { // eslint-disable-l
263358
}
264359
}
265360
// Check whether we were provided empty ndarrays...
266-
if ( len === 0 || numel( shc ) === 0 ) {
361+
if ( len === 0 || ( shc.length && numel( shc ) === 0 ) ) {
267362
return;
268363
}
269364
// Initialize ndarray-like objects for representing sub-array views...

0 commit comments

Comments
 (0)