Skip to content

Commit d1bc036

Browse files
committed
feat: add support for enforcing traversal order
--- 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: skipped - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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 aa7edbf commit d1bc036

File tree

5 files changed

+164
-11
lines changed

5 files changed

+164
-11
lines changed

lib/node_modules/@stdlib/ndarray/base/unary-strided1d-dispatch/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ limitations under the License.
3030
var UnaryStrided1dDispatch = require( '@stdlib/ndarray/base/unary-strided1d-dispatch' );
3131
```
3232

33-
#### UnaryStrided1dDispatch( table, idtypes, odtypes, policies )
33+
#### UnaryStrided1dDispatch( table, idtypes, odtypes, policies\[, options] )
3434

3535
Returns an interface for applying a strided function to an input ndarray.
3636

@@ -70,6 +70,12 @@ The constructor has the following parameters:
7070
- **output**: output data type [policy][@stdlib/ndarray/output-dtype-policies].
7171
- **casting**: input ndarray casting [policy][@stdlib/ndarray/input-casting-policies].
7272

73+
- **options**: function options (_optional_).
74+
75+
The constructor supports the following options:
76+
77+
- **strictTraversalOrder**: boolean specifying whether the order of element traversal must match the memory layout order of an input ndarray. Default: `false`.
78+
7379
#### UnaryStrided1dDispatch.prototype.apply( x\[, ...args]\[, options] )
7480

7581
Applies a strided function to a provided input ndarray.

lib/node_modules/@stdlib/ndarray/base/unary-strided1d-dispatch/docs/repl.txt

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

2-
{{alias}}( table, idtypes, odtypes, policies )
2+
{{alias}}( table, idtypes, odtypes, policies[, options] )
33
Returns an ndarray function interface for applying a strided function to an
44
input ndarray.
55

@@ -42,6 +42,13 @@
4242
- output: output data type policy.
4343
- casting: input ndarray casting policy.
4444

45+
options: Object (optional)
46+
Function options.
47+
48+
options.strictTraversalOrder: boolean (optional)
49+
Boolean specifying whether the order of element traversal must match the
50+
memory layout order of an input ndarray.
51+
4552
Returns
4653
-------
4754
out: Object

lib/node_modules/@stdlib/ndarray/base/unary-strided1d-dispatch/docs/types/index.d.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ interface Options extends BaseOptions {
5353
dtype?: DataType;
5454
}
5555

56+
/**
57+
* Interface defining constructor options.
58+
*/
59+
interface ConstructorOptions {
60+
/**
61+
* Boolean specifying whether the order of element traversal must match the memory layout of an input ndarray.
62+
*/
63+
strictTraversalOrder?: boolean;
64+
}
65+
5666
/**
5767
* Strided function.
5868
*
@@ -122,6 +132,7 @@ declare class UnaryStrided1dDispatch<T, U> {
122132
* @param idtypes - list containing lists of supported input data types for each ndarray argument
123133
* @param odtypes - list of supported output data types
124134
* @param policies - dispatch policies
135+
* @param options - function options
125136
* @returns instance
126137
*
127138
* @example
@@ -151,7 +162,7 @@ declare class UnaryStrided1dDispatch<T, U> {
151162
* var arr = ndarray2array( y );
152163
* // returns [ -1.0, 2.0, 2.0 ]
153164
*/
154-
constructor( table: DispatchTable<T, U> | BaseDispatchTable<T, U>, idtypes: ArrayLike<ArrayLike<DataType>>, odtypes: ArrayLike<DataType>, policies: Policies );
165+
constructor( table: DispatchTable<T, U> | BaseDispatchTable<T, U>, idtypes: ArrayLike<ArrayLike<DataType>>, odtypes: ArrayLike<DataType>, policies: Policies, options?: ConstructorOptions );
155166

156167
/**
157168
* Applies a strided function to a provided input ndarray.
@@ -287,6 +298,7 @@ interface UnaryStrided1dDispatchConstructor {
287298
* @param idtypes - list containing lists of supported input data types for each ndarray argument
288299
* @param odtypes - list of supported output data types
289300
* @param policies - dispatch policies
301+
* @param options - function options
290302
* @returns instance
291303
*
292304
* @example
@@ -316,7 +328,7 @@ interface UnaryStrided1dDispatchConstructor {
316328
* var arr = ndarray2array( y );
317329
* // returns [ -1.0, 2.0, 2.0 ]
318330
*/
319-
new<T = unknown, U = unknown>( table: DispatchTable<T, U> | BaseDispatchTable<T, U>, idtypes: ArrayLike<ArrayLike<DataType>>, odtypes: ArrayLike<DataType>, policies: Policies ): UnaryStrided1dDispatch<T, U>;
331+
new<T = unknown, U = unknown>( table: DispatchTable<T, U> | BaseDispatchTable<T, U>, idtypes: ArrayLike<ArrayLike<DataType>>, odtypes: ArrayLike<DataType>, policies: Policies, options?: ConstructorOptions ): UnaryStrided1dDispatch<T, U>;
320332

321333
/**
322334
* Constructor for applying a strided function to an input ndarray.
@@ -325,6 +337,7 @@ interface UnaryStrided1dDispatchConstructor {
325337
* @param idtypes - list containing lists of supported input data types for each ndarray argument
326338
* @param odtypes - list of supported output data types
327339
* @param policies - dispatch policies
340+
* @param options - function options
328341
* @returns instance
329342
*
330343
* @example
@@ -354,7 +367,7 @@ interface UnaryStrided1dDispatchConstructor {
354367
* var arr = ndarray2array( y );
355368
* // returns [ -1.0, 2.0, 2.0 ]
356369
*/
357-
<T = unknown, U = unknown>( table: DispatchTable<T, U> | BaseDispatchTable<T, U>, idtypes: ArrayLike<ArrayLike<DataType>>, odtypes: ArrayLike<DataType>, policies: Policies ): UnaryStrided1dDispatch<T, U>;
370+
<T = unknown, U = unknown>( table: DispatchTable<T, U> | BaseDispatchTable<T, U>, idtypes: ArrayLike<ArrayLike<DataType>>, odtypes: ArrayLike<DataType>, policies: Policies, options?: ConstructorOptions ): UnaryStrided1dDispatch<T, U>;
358371
}
359372

360373
/**
@@ -364,6 +377,7 @@ interface UnaryStrided1dDispatchConstructor {
364377
* @param idtypes - list containing lists of supported input data types for each ndarray argument
365378
* @param odtypes - list of supported output data types
366379
* @param policies - dispatch policies
380+
* @param options - function options
367381
* @returns instance
368382
*
369383
* @example

lib/node_modules/@stdlib/ndarray/base/unary-strided1d-dispatch/docs/types/test.ts

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ import UnaryStrided1dDispatch = require( './index' );
4141

4242
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies ); // $ExpectType UnaryStrided1dDispatch<number, number>
4343

44+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, {} ); // $ExpectType UnaryStrided1dDispatch<number, number>
45+
4446
const unary = UnaryStrided1dDispatch;
4547
unary<number, number>( table, [ dtypes ], dtypes, policies ); // $ExpectType UnaryStrided1dDispatch<number, number>
48+
unary<number, number>( table, [ dtypes ], dtypes, policies, {} ); // $ExpectType UnaryStrided1dDispatch<number, number>
4649
}
4750

4851
// The compiler throws an error if the function is provided a first argument which is not a dispatch table...
@@ -64,6 +67,17 @@ import UnaryStrided1dDispatch = require( './index' );
6467
new UnaryStrided1dDispatch( {}, [ dtypes ], dtypes, policies ); // $ExpectError
6568
new UnaryStrided1dDispatch( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, policies ); // $ExpectError
6669

70+
new UnaryStrided1dDispatch( '5', [ dtypes ], dtypes, policies, {} ); // $ExpectError
71+
new UnaryStrided1dDispatch( 5, [ dtypes ], dtypes, policies, {} ); // $ExpectError
72+
new UnaryStrided1dDispatch( true, [ dtypes ], dtypes, policies, {} ); // $ExpectError
73+
new UnaryStrided1dDispatch( false, [ dtypes ], dtypes, policies, {} ); // $ExpectError
74+
new UnaryStrided1dDispatch( null, [ dtypes ], dtypes, policies, {} ); // $ExpectError
75+
new UnaryStrided1dDispatch( void 0, [ dtypes ], dtypes, policies, {} ); // $ExpectError
76+
new UnaryStrided1dDispatch( 'abc', [ dtypes ], dtypes, policies, {} ); // $ExpectError
77+
new UnaryStrided1dDispatch( [], [ dtypes ], dtypes, policies, {} ); // $ExpectError
78+
new UnaryStrided1dDispatch( {}, [ dtypes ], dtypes, policies, {} ); // $ExpectError
79+
new UnaryStrided1dDispatch( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, policies, {} ); // $ExpectError
80+
6781
const unary = UnaryStrided1dDispatch;
6882
unary( '5', [ dtypes ], dtypes, policies ); // $ExpectError
6983
unary( 5, [ dtypes ], dtypes, policies ); // $ExpectError
@@ -75,6 +89,17 @@ import UnaryStrided1dDispatch = require( './index' );
7589
unary( [], [ dtypes ], dtypes, policies ); // $ExpectError
7690
unary( {}, [ dtypes ], dtypes, policies ); // $ExpectError
7791
unary( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, policies ); // $ExpectError
92+
93+
unary( '5', [ dtypes ], dtypes, policies, {} ); // $ExpectError
94+
unary( 5, [ dtypes ], dtypes, policies, {} ); // $ExpectError
95+
unary( true, [ dtypes ], dtypes, policies, {} ); // $ExpectError
96+
unary( false, [ dtypes ], dtypes, policies, {} ); // $ExpectError
97+
unary( null, [ dtypes ], dtypes, policies, {} ); // $ExpectError
98+
unary( void 0, [ dtypes ], dtypes, policies, {} ); // $ExpectError
99+
unary( 'abc', [ dtypes ], dtypes, policies, {} ); // $ExpectError
100+
unary( [], [ dtypes ], dtypes, policies, {} ); // $ExpectError
101+
unary( {}, [ dtypes ], dtypes, policies, {} ); // $ExpectError
102+
unary( ( x: number, y: number ): number => x + y, [ dtypes ], dtypes, policies, {} ); // $ExpectError
78103
}
79104

80105
// The compiler throws an error if the function is provided a second argument which is not a a list of data type lists...
@@ -98,6 +123,16 @@ import UnaryStrided1dDispatch = require( './index' );
98123
new UnaryStrided1dDispatch<number, number>( table, {}, dtypes, policies ); // $ExpectError
99124
new UnaryStrided1dDispatch<number, number>( table, ( x: number ): number => x, dtypes, policies ); // $ExpectError
100125

126+
new UnaryStrided1dDispatch<number, number>( table, '5', dtypes, policies, {} ); // $ExpectError
127+
new UnaryStrided1dDispatch<number, number>( table, 5, dtypes, policies, {} ); // $ExpectError
128+
new UnaryStrided1dDispatch<number, number>( table, true, dtypes, policies, {} ); // $ExpectError
129+
new UnaryStrided1dDispatch<number, number>( table, false, dtypes, policies, {} ); // $ExpectError
130+
new UnaryStrided1dDispatch<number, number>( table, null, dtypes, policies, {} ); // $ExpectError
131+
new UnaryStrided1dDispatch<number, number>( table, void 0, dtypes, policies, {} ); // $ExpectError
132+
new UnaryStrided1dDispatch<number, number>( table, 'abc', dtypes, policies, {} ); // $ExpectError
133+
new UnaryStrided1dDispatch<number, number>( table, {}, dtypes, policies, {} ); // $ExpectError
134+
new UnaryStrided1dDispatch<number, number>( table, ( x: number ): number => x, dtypes, policies, {} ); // $ExpectError
135+
101136
const unary = UnaryStrided1dDispatch;
102137
unary<number, number>( table, '5', dtypes, policies ); // $ExpectError
103138
unary<number, number>( table, 5, dtypes, policies ); // $ExpectError
@@ -108,6 +143,16 @@ import UnaryStrided1dDispatch = require( './index' );
108143
unary<number, number>( table, 'abc', dtypes, policies ); // $ExpectError
109144
unary<number, number>( table, {}, dtypes, policies ); // $ExpectError
110145
unary<number, number>( table, ( x: number ): number => x, dtypes, policies ); // $ExpectError
146+
147+
unary<number, number>( table, '5', dtypes, policies, {} ); // $ExpectError
148+
unary<number, number>( table, 5, dtypes, policies, {} ); // $ExpectError
149+
unary<number, number>( table, true, dtypes, policies, {} ); // $ExpectError
150+
unary<number, number>( table, false, dtypes, policies, {} ); // $ExpectError
151+
unary<number, number>( table, null, dtypes, policies, {} ); // $ExpectError
152+
unary<number, number>( table, void 0, dtypes, policies, {} ); // $ExpectError
153+
unary<number, number>( table, 'abc', dtypes, policies, {} ); // $ExpectError
154+
unary<number, number>( table, {}, dtypes, policies, {} ); // $ExpectError
155+
unary<number, number>( table, ( x: number ): number => x, dtypes, policies, {} ); // $ExpectError
111156
}
112157

113158
// The compiler throws an error if the function is provided a third argument which is not a list of data types...
@@ -131,6 +176,16 @@ import UnaryStrided1dDispatch = require( './index' );
131176
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], {}, policies ); // $ExpectError
132177
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], ( x: number ): number => x, policies ); // $ExpectError
133178

179+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], '5', policies, {} ); // $ExpectError
180+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], 5, policies, {} ); // $ExpectError
181+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], true, policies, {} ); // $ExpectError
182+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], false, policies, {} ); // $ExpectError
183+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], null, policies, {} ); // $ExpectError
184+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], void 0, policies, {} ); // $ExpectError
185+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], 'abc', policies, {} ); // $ExpectError
186+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], {}, policies, {} ); // $ExpectError
187+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], ( x: number ): number => x, policies, {} ); // $ExpectError
188+
134189
const unary = UnaryStrided1dDispatch;
135190
unary<number, number>( table, [ dtypes ], '5', policies ); // $ExpectError
136191
unary<number, number>( table, [ dtypes ], 5, policies ); // $ExpectError
@@ -141,6 +196,16 @@ import UnaryStrided1dDispatch = require( './index' );
141196
unary<number, number>( table, [ dtypes ], 'abc', policies ); // $ExpectError
142197
unary<number, number>( table, [ dtypes ], {}, policies ); // $ExpectError
143198
unary<number, number>( table, [ dtypes ], ( x: number ): number => x, policies ); // $ExpectError
199+
200+
unary<number, number>( table, [ dtypes ], '5', policies, {} ); // $ExpectError
201+
unary<number, number>( table, [ dtypes ], 5, policies, {} ); // $ExpectError
202+
unary<number, number>( table, [ dtypes ], true, policies, {} ); // $ExpectError
203+
unary<number, number>( table, [ dtypes ], false, policies, {} ); // $ExpectError
204+
unary<number, number>( table, [ dtypes ], null, policies, {} ); // $ExpectError
205+
unary<number, number>( table, [ dtypes ], void 0, policies, {} ); // $ExpectError
206+
unary<number, number>( table, [ dtypes ], 'abc', policies, {} ); // $ExpectError
207+
unary<number, number>( table, [ dtypes ], {}, policies, {} ); // $ExpectError
208+
unary<number, number>( table, [ dtypes ], ( x: number ): number => x, policies, {} ); // $ExpectError
144209
}
145210

146211
// The compiler throws an error if the function is provided a fourth argument which is not valid policy object...
@@ -160,6 +225,16 @@ import UnaryStrided1dDispatch = require( './index' );
160225
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, {} ); // $ExpectError
161226
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, ( x: number ): number => x ); // $ExpectError
162227

228+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, '5', {} ); // $ExpectError
229+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, 5, {} ); // $ExpectError
230+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, true, {} ); // $ExpectError
231+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, false, {} ); // $ExpectError
232+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, null, {} ); // $ExpectError
233+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, void 0, {} ); // $ExpectError
234+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, 'abc', {} ); // $ExpectError
235+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, {}, {} ); // $ExpectError
236+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, ( x: number ): number => x, {} ); // $ExpectError
237+
163238
const unary = UnaryStrided1dDispatch;
164239
unary<number, number>( table, [ dtypes ], dtypes, '5' ); // $ExpectError
165240
unary<number, number>( table, [ dtypes ], dtypes, 5 ); // $ExpectError
@@ -170,6 +245,45 @@ import UnaryStrided1dDispatch = require( './index' );
170245
unary<number, number>( table, [ dtypes ], dtypes, 'abc' ); // $ExpectError
171246
unary<number, number>( table, [ dtypes ], dtypes, {} ); // $ExpectError
172247
unary<number, number>( table, [ dtypes ], dtypes, ( x: number ): number => x ); // $ExpectError
248+
249+
unary<number, number>( table, [ dtypes ], dtypes, '5', {} ); // $ExpectError
250+
unary<number, number>( table, [ dtypes ], dtypes, 5, {} ); // $ExpectError
251+
unary<number, number>( table, [ dtypes ], dtypes, true, {} ); // $ExpectError
252+
unary<number, number>( table, [ dtypes ], dtypes, false, {} ); // $ExpectError
253+
unary<number, number>( table, [ dtypes ], dtypes, null, {} ); // $ExpectError
254+
unary<number, number>( table, [ dtypes ], dtypes, void 0, {} ); // $ExpectError
255+
unary<number, number>( table, [ dtypes ], dtypes, 'abc', {} ); // $ExpectError
256+
unary<number, number>( table, [ dtypes ], dtypes, {}, {} ); // $ExpectError
257+
unary<number, number>( table, [ dtypes ], dtypes, ( x: number ): number => x, {} ); // $ExpectError
258+
}
259+
260+
// The compiler throws an error if the function is provided a fifth argument which is an object...
261+
{
262+
const dtypes: Array<DataType> = [ 'float64', 'float32' ];
263+
const table = {
264+
'default': cumax
265+
};
266+
const policies = {
267+
'output': 'same' as OutputPolicy,
268+
'casting': 'none' as InputCastingPolicy
269+
};
270+
271+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, '5' ); // $ExpectError
272+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, 5 ); // $ExpectError
273+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, true ); // $ExpectError
274+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, false ); // $ExpectError
275+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, null ); // $ExpectError
276+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, 'abc' ); // $ExpectError
277+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, ( x: number ): number => x ); // $ExpectError
278+
279+
const unary = UnaryStrided1dDispatch;
280+
unary<number, number>( table, [ dtypes ], dtypes, policies, '5' ); // $ExpectError
281+
unary<number, number>( table, [ dtypes ], dtypes, policies, 5 ); // $ExpectError
282+
unary<number, number>( table, [ dtypes ], dtypes, policies, true ); // $ExpectError
283+
unary<number, number>( table, [ dtypes ], dtypes, policies, false ); // $ExpectError
284+
unary<number, number>( table, [ dtypes ], dtypes, policies, null ); // $ExpectError
285+
unary<number, number>( table, [ dtypes ], dtypes, policies, 'abc' ); // $ExpectError
286+
unary<number, number>( table, [ dtypes ], dtypes, policies, ( x: number ): number => x ); // $ExpectError
173287
}
174288

175289
// The compiler throws an error if the function is provided an unsupported number of arguments...
@@ -186,13 +300,13 @@ import UnaryStrided1dDispatch = require( './index' );
186300
new UnaryStrided1dDispatch(); // $ExpectError
187301
new UnaryStrided1dDispatch<number, number>( table ); // $ExpectError
188302
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ] ); // $ExpectError
189-
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, {} ); // $ExpectError
303+
new UnaryStrided1dDispatch<number, number>( table, [ dtypes ], dtypes, policies, {}, {} ); // $ExpectError
190304

191305
const unary = UnaryStrided1dDispatch;
192306
unary(); // $ExpectError
193307
unary<number, number>( table ); // $ExpectError
194308
unary<number, number>( table, [ dtypes ] ); // $ExpectError
195-
unary<number, number>( table, [ dtypes ], dtypes, policies, {} ); // $ExpectError
309+
unary<number, number>( table, [ dtypes ], dtypes, policies, {}, {} ); // $ExpectError
196310
}
197311

198312
// The function returns an instance having an `apply` method which returns an ndarray...

0 commit comments

Comments
 (0)