Skip to content

Commit a092619

Browse files
committed
Auto-generated commit
1 parent c8d3ae4 commit a092619

6 files changed

Lines changed: 199 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010

1111
### Features
1212

13+
- [`ba6c568`](https://github.com/stdlib-js/stdlib/commit/ba6c568030bf47a3b8c8b2297e5d87fc093ed93b) - add `toReversed` to namespace
14+
- [`853fe75`](https://github.com/stdlib-js/stdlib/commit/853fe75bce7b8374fd7545c493cc89391b20636f) - add `shift` to namespace
15+
- [`e7715c7`](https://github.com/stdlib-js/stdlib/commit/e7715c7f1f74f3734ba9b7d5d367ea02b415b66e) - add `reverseDimension` to namespace
16+
- [`d07a5e1`](https://github.com/stdlib-js/stdlib/commit/d07a5e192a71096281f503feafa37869eb3748d8) - add `reverse` to namespace
17+
- [`1fb2b08`](https://github.com/stdlib-js/stdlib/commit/1fb2b0825c39f1684e43d13c021250d18e39a0ac) - add `pop` to namespace
18+
- [`bcedc5c`](https://github.com/stdlib-js/stdlib/commit/bcedc5c77b7bf65e93889ed4eea5b4476a738c4a) - add `flattenFrom` to namespace
19+
- [`c556b67`](https://github.com/stdlib-js/stdlib/commit/c556b67ae35b5c82e6620c2b3d3c91a22ac041d2) - add `find` to namespace
20+
- [`4365728`](https://github.com/stdlib-js/stdlib/commit/436572826828fdd56092f08ea927f6d25ad3aa02) - add `concat` to namespace
21+
- [`8b5a852`](https://github.com/stdlib-js/stdlib/commit/8b5a852ce0854b3676ea6f6dc6ed03008b502883) - add `anyBy` to namespace
22+
- [`6509ab5`](https://github.com/stdlib-js/stdlib/commit/6509ab543ec9b712cccb2f1d2527b0257bda88c0) - add `any` to namespace
23+
- [`8e0d78b`](https://github.com/stdlib-js/stdlib/commit/8e0d78b71b20d19c573df9730e3891eaba82c1d3) - add `copy` to namespace
1324
- [`e23e0c4`](https://github.com/stdlib-js/stdlib/commit/e23e0c4afb1a711ddc091197ea4dac8888aca03f) - add `ndarray/copy` [(#8490)](https://github.com/stdlib-js/stdlib/pull/8490)
1425
- [`cad6845`](https://github.com/stdlib-js/stdlib/commit/cad68452e8d2a52ebe1ebfd74117d98197a4a568) - add `isComplexFloatingPointDataTypeChar` to namespace
1526
- [`b8c50f8`](https://github.com/stdlib-js/stdlib/commit/b8c50f8cb3942eeb670d144cb4089ff30ed7370b) - add `ndarray/base/assert/is-complex-floating-point-data-type-char`
@@ -456,6 +467,8 @@
456467

457468
### Bug Fixes
458469

470+
- [`83a01e7`](https://github.com/stdlib-js/stdlib/commit/83a01e723e9037a2c402c1e60b54bc678ef27078) - enforce mostly-safe casting
471+
- [`e33ce98`](https://github.com/stdlib-js/stdlib/commit/e33ce98738a5fb62a81d17dbcd8b1b2606c6f208) - enforce mostly-safe casting
459472
- [`97fb507`](https://github.com/stdlib-js/stdlib/commit/97fb507addda8bf32be3a3f376d387e528672149) - handle mostly safe casts and refactor loop generation
460473
- [`ef3f025`](https://github.com/stdlib-js/stdlib/commit/ef3f025dad7f2b8a5a451b9cc3ec822cc66c1c2a) - address copy-paste mistake
461474
- [`186033e`](https://github.com/stdlib-js/stdlib/commit/186033e3cccf7faffaad1c101404de68f688027e) - address off-by-one bug
@@ -625,6 +638,19 @@ A total of 32 issues were closed in this release:
625638

626639
<details>
627640

641+
- [`ba6c568`](https://github.com/stdlib-js/stdlib/commit/ba6c568030bf47a3b8c8b2297e5d87fc093ed93b) - **feat:** add `toReversed` to namespace _(by Athan Reines)_
642+
- [`853fe75`](https://github.com/stdlib-js/stdlib/commit/853fe75bce7b8374fd7545c493cc89391b20636f) - **feat:** add `shift` to namespace _(by Athan Reines)_
643+
- [`e7715c7`](https://github.com/stdlib-js/stdlib/commit/e7715c7f1f74f3734ba9b7d5d367ea02b415b66e) - **feat:** add `reverseDimension` to namespace _(by Athan Reines)_
644+
- [`d07a5e1`](https://github.com/stdlib-js/stdlib/commit/d07a5e192a71096281f503feafa37869eb3748d8) - **feat:** add `reverse` to namespace _(by Athan Reines)_
645+
- [`1fb2b08`](https://github.com/stdlib-js/stdlib/commit/1fb2b0825c39f1684e43d13c021250d18e39a0ac) - **feat:** add `pop` to namespace _(by Athan Reines)_
646+
- [`bcedc5c`](https://github.com/stdlib-js/stdlib/commit/bcedc5c77b7bf65e93889ed4eea5b4476a738c4a) - **feat:** add `flattenFrom` to namespace _(by Athan Reines)_
647+
- [`c556b67`](https://github.com/stdlib-js/stdlib/commit/c556b67ae35b5c82e6620c2b3d3c91a22ac041d2) - **feat:** add `find` to namespace _(by Athan Reines)_
648+
- [`4365728`](https://github.com/stdlib-js/stdlib/commit/436572826828fdd56092f08ea927f6d25ad3aa02) - **feat:** add `concat` to namespace _(by Athan Reines)_
649+
- [`8b5a852`](https://github.com/stdlib-js/stdlib/commit/8b5a852ce0854b3676ea6f6dc6ed03008b502883) - **feat:** add `anyBy` to namespace _(by Athan Reines)_
650+
- [`6509ab5`](https://github.com/stdlib-js/stdlib/commit/6509ab543ec9b712cccb2f1d2527b0257bda88c0) - **feat:** add `any` to namespace _(by Athan Reines)_
651+
- [`8e0d78b`](https://github.com/stdlib-js/stdlib/commit/8e0d78b71b20d19c573df9730e3891eaba82c1d3) - **feat:** add `copy` to namespace _(by Athan Reines)_
652+
- [`83a01e7`](https://github.com/stdlib-js/stdlib/commit/83a01e723e9037a2c402c1e60b54bc678ef27078) - **fix:** enforce mostly-safe casting _(by Athan Reines)_
653+
- [`e33ce98`](https://github.com/stdlib-js/stdlib/commit/e33ce98738a5fb62a81d17dbcd8b1b2606c6f208) - **fix:** enforce mostly-safe casting _(by Athan Reines)_
628654
- [`73b90f9`](https://github.com/stdlib-js/stdlib/commit/73b90f98e772d959db84ae6c7e680469e3641e45) - **docs:** update examples _(by Athan Reines)_
629655
- [`3041dd6`](https://github.com/stdlib-js/stdlib/commit/3041dd64033596c03a6ed59f1a3e638fd48d4540) - **test:** use accessor functions and update docs _(by Athan Reines)_
630656
- [`e23e0c4`](https://github.com/stdlib-js/stdlib/commit/e23e0c4afb1a711ddc091197ea4dac8888aca03f) - **feat:** add `ndarray/copy` [(#8490)](https://github.com/stdlib-js/stdlib/pull/8490) _(by Muhammad Haris, Athan Reines)_

‎flatten-from/lib/main.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isPlainObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
2626
var isInteger = require( '@stdlib/assert/is-integer' );
27+
var isMostlySafeCast = require( './../../base/assert/is-mostly-safe-data-type-cast' );
2728
var isOrder = require( './../../base/assert/is-order' );
2829
var getShape = require( './../../shape' );
2930
var getOrder = require( './../../order' );
@@ -334,7 +335,9 @@ function flattenFrom( x, dim, options ) {
334335
}
335336
}
336337
if ( hasOwnProp( options, 'dtype' ) ) {
337-
// Delegate `dtype` validation to `emptyLike` during output array creation:
338+
if ( !isMostlySafeCast( opts.dtype, options.dtype ) ) {
339+
throw new TypeError( format( 'invalid option. First argument cannot be safely cast to the specified data type. Input data type: %s. Option: `%s`.', String( opts.dtype ), String( options.dtype ) ) );
340+
}
338341
opts.dtype = options.dtype;
339342
}
340343
}

‎flatten-from/test/test.js‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
var tape = require( 'tape' );
2626
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
2727
var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' );
28+
var empty = require( './../../empty' );
2829
var zeros = require( './../../zeros' );
2930
var ndarray = require( './../../ctor' );
3031
var Float64Array = require( '@stdlib/array/float64' );
@@ -269,6 +270,38 @@ tape( 'the function throws an error if provided an invalid `dtype` option', func
269270
}
270271
});
271272

273+
tape( 'the function throws an error if provided a first argument which cannot be safely cast to a specified `dtype` option', function test( t ) {
274+
var values;
275+
var x;
276+
var i;
277+
278+
x = empty( [ 2, 2 ], {
279+
'dtype': 'bool'
280+
});
281+
282+
values = [
283+
'float64',
284+
'complex128',
285+
'float32',
286+
'complex64',
287+
'int32'
288+
];
289+
290+
for ( i = 0; i < values.length; i++ ) {
291+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+ values[i] );
292+
}
293+
t.end();
294+
295+
function badValue( value ) {
296+
return function badValue() {
297+
var opts = {
298+
'dtype': value
299+
};
300+
flattenFrom( x, 0, opts );
301+
};
302+
}
303+
});
304+
272305
tape( 'by default, the function flattens all dimensions of a provided input ndarray starting from a specified dimension in lexicographic order (row-major, contiguous)', function test( t ) {
273306
var expected;
274307
var xbuf;

‎flatten/lib/main.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isPlainObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
2626
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' );
27+
var isMostlySafeCast = require( './../../base/assert/is-mostly-safe-data-type-cast' );
2728
var isOrder = require( './../../base/assert/is-order' );
2829
var getShape = require( './../../shape' );
2930
var getOrder = require( './../../order' );
@@ -336,7 +337,9 @@ function flatten( x, options ) {
336337
}
337338
}
338339
if ( hasOwnProp( options, 'dtype' ) ) {
339-
// Delegate `dtype` validation to `emptyLike` during output array creation:
340+
if ( !isMostlySafeCast( opts.dtype, options.dtype ) ) {
341+
throw new TypeError( format( 'invalid option. First argument cannot be safely cast to the specified data type. Input data type: %s. Option: `%s`.', String( opts.dtype ), String( options.dtype ) ) );
342+
}
340343
opts.dtype = options.dtype;
341344
}
342345
}

‎flatten/test/test.js‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var tape = require( 'tape' );
2626
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
2727
var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' );
2828
var zeros = require( './../../zeros' );
29+
var empty = require( './../../empty' );
2930
var ndarray = require( './../../ctor' );
3031
var Float64Array = require( '@stdlib/array/float64' );
3132
var Float32Array = require( '@stdlib/array/float32' );
@@ -226,6 +227,38 @@ tape( 'the function throws an error if provided an invalid `dtype` option', func
226227
}
227228
});
228229

230+
tape( 'the function throws an error if provided a first argument which cannot be safely cast to a specified `dtype` option', function test( t ) {
231+
var values;
232+
var x;
233+
var i;
234+
235+
x = empty( [ 2, 2 ], {
236+
'dtype': 'bool'
237+
});
238+
239+
values = [
240+
'float64',
241+
'complex128',
242+
'float32',
243+
'complex64',
244+
'int32'
245+
];
246+
247+
for ( i = 0; i < values.length; i++ ) {
248+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+ values[i] );
249+
}
250+
t.end();
251+
252+
function badValue( value ) {
253+
return function badValue() {
254+
var opts = {
255+
'dtype': value
256+
};
257+
flatten( x, opts );
258+
};
259+
}
260+
});
261+
229262
tape( 'by default, the function flattens all dimensions of a provided input ndarray in lexicographic order (row-major, contiguous)', function test( t ) {
230263
var expected;
231264
var xbuf;

‎lib/index.js‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ var setReadOnly = require( '@stdlib/utils/define-read-only-property' );
3636
*/
3737
var ns = {};
3838

39+
/**
40+
* @name any
41+
* @memberof ns
42+
* @readonly
43+
* @type {Function}
44+
* @see {@link module:@stdlib/ndarray/any}
45+
*/
46+
setReadOnly( ns, 'any', require( './../any' ) );
47+
48+
/**
49+
* @name anyBy
50+
* @memberof ns
51+
* @readonly
52+
* @type {Function}
53+
* @see {@link module:@stdlib/ndarray/any-by}
54+
*/
55+
setReadOnly( ns, 'anyBy', require( './../any-by' ) );
56+
3957
/**
4058
* @name array
4159
* @memberof ns
@@ -90,6 +108,24 @@ setReadOnly( ns, 'broadcastArrays', require( './../broadcast-arrays' ) );
90108
*/
91109
setReadOnly( ns, 'castingModes', require( './../casting-modes' ) );
92110

111+
/**
112+
* @name concat
113+
* @memberof ns
114+
* @readonly
115+
* @type {Function}
116+
* @see {@link module:@stdlib/ndarray/concat}
117+
*/
118+
setReadOnly( ns, 'concat', require( './../concat' ) );
119+
120+
/**
121+
* @name copy
122+
* @memberof ns
123+
* @readonly
124+
* @type {Function}
125+
* @see {@link module:@stdlib/ndarray/copy}
126+
*/
127+
setReadOnly( ns, 'copy', require( './../copy' ) );
128+
93129
/**
94130
* @name countFalsy
95131
* @memberof ns
@@ -261,6 +297,15 @@ setReadOnly( ns, 'filter', require( './../filter' ) );
261297
*/
262298
setReadOnly( ns, 'filterMap', require( './../filter-map' ) );
263299

300+
/**
301+
* @name find
302+
* @memberof ns
303+
* @readonly
304+
* @type {Function}
305+
* @see {@link module:@stdlib/ndarray/find}
306+
*/
307+
setReadOnly( ns, 'find', require( './../find' ) );
308+
264309
/**
265310
* @name flag
266311
* @memberof ns
@@ -297,6 +342,15 @@ setReadOnly( ns, 'flatten', require( './../flatten' ) );
297342
*/
298343
setReadOnly( ns, 'flattenBy', require( './../flatten-by' ) );
299344

345+
/**
346+
* @name flattenFrom
347+
* @memberof ns
348+
* @readonly
349+
* @type {Function}
350+
* @see {@link module:@stdlib/ndarray/flatten-from}
351+
*/
352+
setReadOnly( ns, 'flattenFrom', require( './../flatten-from' ) );
353+
300354
/**
301355
* @name forEach
302356
* @memberof ns
@@ -495,6 +549,15 @@ setReadOnly( ns, 'orders', require( './../orders' ) );
495549
*/
496550
setReadOnly( ns, 'outputDataTypePolicies', require( './../output-dtype-policies' ) );
497551

552+
/**
553+
* @name pop
554+
* @memberof ns
555+
* @readonly
556+
* @type {Function}
557+
* @see {@link module:@stdlib/ndarray/pop}
558+
*/
559+
setReadOnly( ns, 'pop', require( './../pop' ) );
560+
498561
/**
499562
* @name promotionRules
500563
* @memberof ns
@@ -513,6 +576,24 @@ setReadOnly( ns, 'promotionRules', require( './../promotion-rules' ) );
513576
*/
514577
setReadOnly( ns, 'reject', require( './../reject' ) );
515578

579+
/**
580+
* @name reverse
581+
* @memberof ns
582+
* @readonly
583+
* @type {Function}
584+
* @see {@link module:@stdlib/ndarray/reverse}
585+
*/
586+
setReadOnly( ns, 'reverse', require( './../reverse' ) );
587+
588+
/**
589+
* @name reverseDimension
590+
* @memberof ns
591+
* @readonly
592+
* @type {Function}
593+
* @see {@link module:@stdlib/ndarray/reverse-dimension}
594+
*/
595+
setReadOnly( ns, 'reverseDimension', require( './../reverse-dimension' ) );
596+
516597
/**
517598
* @name safeCasts
518599
* @memberof ns
@@ -540,6 +621,15 @@ setReadOnly( ns, 'sameKindCasts', require( './../same-kind-casts' ) );
540621
*/
541622
setReadOnly( ns, 'shape', require( './../shape' ) );
542623

624+
/**
625+
* @name shift
626+
* @memberof ns
627+
* @readonly
628+
* @type {Function}
629+
* @see {@link module:@stdlib/ndarray/shift}
630+
*/
631+
setReadOnly( ns, 'shift', require( './../shift' ) );
632+
543633
/**
544634
* @name slice
545635
* @memberof ns
@@ -666,6 +756,15 @@ setReadOnly( ns, 'ndarray2fancy', require( './../to-fancy' ) );
666756
*/
667757
setReadOnly( ns, 'ndarray2json', require( './../to-json' ) );
668758

759+
/**
760+
* @name toReversed
761+
* @memberof ns
762+
* @readonly
763+
* @type {Function}
764+
* @see {@link module:@stdlib/ndarray/to-reversed}
765+
*/
766+
setReadOnly( ns, 'toReversed', require( './../to-reversed' ) );
767+
669768
/**
670769
* @name vector
671770
* @memberof ns

0 commit comments

Comments
 (0)