Skip to content

Commit 59d4439

Browse files
committed
Auto-generated commit
1 parent 6c6b6fb commit 59d4439

13 files changed

Lines changed: 43 additions & 71 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ Returns a list of ndarray casting modes.
7777

7878
```javascript
7979
var out = modes();
80-
// returns [ 'none', 'equiv', 'safe', 'same-kind', 'unsafe' ]
80+
// returns [ 'none', 'equiv', 'safe', 'mostly-safe', 'same-kind', 'unsafe' ]
8181
```
8282

8383
The output `array` contains the following modes:
8484

8585
- `none`: only allow casting between identical types.
8686
- `equiv`: allow casting between identical and byte swapped types.
8787
- `safe`: only allow "safe" casts.
88+
- `mostly-safe`: allow "safe" casts and, for floating-point data types, downcasts.
8889
- `same-kind`: allow "safe" casts and casts within the same kind (e.g., between signed integers or between floats).
8990
- `unsafe`: allow casting between all types (including between integers and floats).
9091

@@ -131,6 +132,9 @@ bool = isMode( 'equiv' );
131132
bool = isMode( 'safe' );
132133
// returns true
133134

135+
bool = isMode( 'mostly-safe' );
136+
// returns true
137+
134138
bool = isMode( 'same-kind' );
135139
// returns true
136140

dist/index.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/repl.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
The output array contains the following modes:
66

7-
- 'none': only allow casting between identical types
8-
- 'equiv': allow casting between identical and byte swapped types
9-
- 'safe': only allow "safe" casts
7+
- 'none': only allow casting between identical types.
8+
- 'equiv': allow casting between identical and byte swapped types.
9+
- 'safe': only allow "safe" casts.
10+
- 'mostly-safe': allow "safe" casts and, for floating-point data types,
11+
downcasts.
1012
- 'same-kind': allow "safe" casts and casts within the same kind (e.g.,
11-
between signed integers or between floats)
13+
between signed integers or between floats).
1214
- 'unsafe': allow casting between all types (including between integers and
13-
floats)
15+
floats).
1416

1517
Returns
1618
-------
@@ -20,7 +22,7 @@
2022
Examples
2123
--------
2224
> var out = {{alias}}()
23-
[ 'none', 'equiv', 'safe', 'same-kind', 'unsafe' ]
25+
[ 'none', 'equiv', 'safe', 'mostly-safe', 'same-kind', 'unsafe' ]
2426

2527
See Also
2628
--------

docs/types/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* - 'none': only allow casting between identical types
2929
* - 'equiv': allow casting between identical and byte swapped types
3030
* - 'safe': only allow "safe" casts
31+
* - 'mostly-safe': allow "safe" casts and, for floating-point data types, downcasts
3132
* - 'same-kind': allow "safe" casts and casts within the same kind (e.g.,
3233
* between signed integers or between floats)
3334
* - 'unsafe': allow casting between all types (including between integers and
@@ -37,7 +38,7 @@
3738
*
3839
* @example
3940
* var list = modes();
40-
* // returns [ 'none', 'equiv', 'safe', 'same-kind', 'unsafe' ]
41+
* // returns [ 'none', 'equiv', 'safe', 'mostly-safe', 'same-kind', 'unsafe' ]
4142
*/
4243
declare function modes(): Array<string>;
4344

examples/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ bool = isMode( 'safe' );
4343
console.log( bool );
4444
// => true
4545

46+
bool = isMode( 'mostly-safe' );
47+
console.log( bool );
48+
// => true
49+
4650
bool = isMode( 'same-kind' );
4751
console.log( bool );
4852
// => true

include/stdlib/ndarray/casting_modes.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ enum STDLIB_NDARRAY_CASTING_MODE {
3232
// Only allow "safe" casts:
3333
STDLIB_NDARRAY_SAFE_CASTING = 2,
3434

35+
// Allow "safe" casts and, for floating-point data types, downcasts:
36+
STDLIB_NDARRAY_MOSTLY_SAFE_CASTING = 3,
37+
3538
// Allow "safe" casts and casts within the same kind (e.g., between signed integers or between floats):
36-
STDLIB_NDARRAY_SAME_KIND_CASTING = 3,
39+
STDLIB_NDARRAY_SAME_KIND_CASTING = 4,
3740

3841
// Allow casting between all types (including between integers and floats):
39-
STDLIB_NDARRAY_UNSAFE_CASTING = 4
42+
STDLIB_NDARRAY_UNSAFE_CASTING = 5
4043
};
4144

4245
#endif // !STDLIB_NDARRAY_CASTING_MODES_H

lib/enum.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ function enumerated() {
4040
'none': 0,
4141
'equiv': 1,
4242
'safe': 2,
43-
'same-kind': 3,
44-
'unsafe': 4
43+
'mostly-safe': 3,
44+
'same-kind': 4,
45+
'unsafe': 5
4546
};
4647
}
4748

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* var modes = require( '@stdlib/ndarray-casting-modes' );
2828
*
2929
* var list = modes();
30-
* // returns [ 'none', 'equiv', 'safe', 'same-kind', 'unsafe' ]
30+
* // returns [ 'none', 'equiv', 'safe', 'mostly-safe', 'same-kind', 'unsafe' ]
3131
*/
3232

3333
// MODULES //

lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var MODES = require( './modes.json' );
3232
*
3333
* @example
3434
* var list = modes();
35-
* // returns [ 'none', 'equiv', 'safe', 'same-kind', 'unsafe' ]
35+
* // returns [ 'none', 'equiv', 'safe', 'mostly-safe', 'same-kind', 'unsafe' ]
3636
*/
3737
function modes() {
3838
return MODES.slice();

0 commit comments

Comments
 (0)