Skip to content

Commit f46c1bd

Browse files
committed
chore: clean-up
--- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - 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 20dd427 commit f46c1bd

File tree

7 files changed

+244
-128
lines changed

7 files changed

+244
-128
lines changed

lib/node_modules/@stdlib/blas/ext/sorthp/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ var bool = ( x === y );
5252

5353
The function has the following parameters:
5454

55-
- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a numeric or "generic" [data type][@stdlib/ndarray/dtypes].
56-
- **sortOrder**: sort order (_optional_). May be either a scalar value, string, or an [ndarray][@stdlib/ndarray/ctor] having a real or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order).
55+
- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes].
56+
- **sortOrder**: sort order (_optional_). May be either a scalar value, string, or an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order).
5757
- **options**: function options (_optional_).
5858

5959
The function accepts the following options:
@@ -130,7 +130,11 @@ v = ndarray2array( y );
130130
## Notes
131131

132132
- The input [ndarray][@stdlib/ndarray/ctor] is sorted **in-place** (i.e., the input [ndarray][@stdlib/ndarray/ctor] is **mutated**).
133-
- If `sortOrder < 0.0` or either `'desc'` or `'descending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **decreasing** order. If `sortOrder > 0.0` or either `'asc'` or `'ascending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **increasing** order. If `sortOrder == 0.0`, the input [ndarray][@stdlib/ndarray/ctor] is left unchanged.
133+
- If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **increasing** order. If `sortOrder == 0.0`, the input [ndarray][@stdlib/ndarray/ctor] is left unchanged.
134+
- The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
135+
- The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
136+
- The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
137+
- The algorithm is **unstable**, meaning that the algorithm may change the order of [ndarray][@stdlib/ndarray/ctor] elements which are equal or equivalent (e.g., `NaN` values).
134138
- The function iterates over [ndarray][@stdlib/ndarray/ctor] elements according to the memory layout of the input [ndarray][@stdlib/ndarray/ctor]. Accordingly, performance degradation is possible when operating over multiple dimensions of a large non-contiguous multi-dimensional input [ndarray][@stdlib/ndarray/ctor]. In such scenarios, one may want to copy an input [ndarray][@stdlib/ndarray/ctor] to contiguous memory before sorting.
135139

136140
</section>

lib/node_modules/@stdlib/blas/ext/sorthp/docs/repl.txt

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,45 @@
22
{{alias}}( x[, sortOrder][, options] )
33
Sorts an input ndarray along one or more ndarray dimensions using heapsort.
44

5+
The algorithm distinguishes between `-0` and `+0`. When sorted in increasing
6+
order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is
7+
sorted after `+0`.
8+
9+
The algorithm sorts `NaN` values to the end. When sorted in increasing
10+
order, `NaN` values are sorted last. When sorted in decreasing order, `NaN`
11+
values are sorted first.
12+
13+
The algorithm has space complexity O(1) and time complexity O(N log2 N).
14+
15+
The algorithm is *unstable*, meaning that the algorithm may change the order
16+
of ndarray elements which are equal or equivalent (e.g., `NaN` values).
17+
518
The function sorts an input ndarray in-place and thus mutates an input
619
ndarray.
720

821
Parameters
922
----------
1023
x: ndarray
11-
Input array. Must have a numeric or "generic" data type.
24+
Input array. Must have a real-valued or "generic" data type.
1225

13-
sortOrder: ndarray|number (optional)
14-
Sort order. May be either a scalar value, string or an ndarray having a
15-
real or "generic" data type. If provided an ndarray, the value must have
16-
a shape which is broadcast compatible with the complement of the shape
17-
defined by `options.dims`. For example, given the input shape
26+
sortOrder: ndarray|number|string (optional)
27+
Sort order. May be either a scalar value, string, or an ndarray having a
28+
real-valued or "generic" data type. If provided an ndarray, the value
29+
must have a shape which is broadcast compatible with the complement of
30+
the shape defined by `options.dims`. For example, given the input shape
1831
`[2, 3, 4]` and `options.dims=[0]`, an ndarray sort order must have a
1932
shape which is broadcast compatible with the shape `[3, 4]`. Similarly,
2033
when performing the operation over all elements in a provided input
21-
ndarray, an ndarray sort order must be a zero-dimensional ndarray. By
22-
default, the sort order is `1` (i.e., increasing order).
34+
ndarray, an ndarray sort order must be a zero-dimensional ndarray.
35+
36+
If specified as a string, must be one of the following values:
37+
38+
- ascending: sort in increasing order.
39+
- asc: sort in increasing order.
40+
- descending: sort in decreasing order.
41+
- desc: sort in decreasing order.
42+
43+
By default, the sort order is `1` (i.e., increasing order).
2344

2445
options: Object (optional)
2546
Function options.

lib/node_modules/@stdlib/blas/ext/sorthp/docs/types/index.d.ts

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
/// <reference types="@stdlib/types"/>
2222

2323
import { ArrayLike } from '@stdlib/types/array';
24-
import { typedndarray, RealAndGenericDataType as DataType } from '@stdlib/types/ndarray';
24+
import { typedndarray, realndarray, genericndarray } from '@stdlib/types/ndarray';
2525

2626
/**
2727
* Input array.
2828
*/
29-
type InputArray<T> = typedndarray<T>;
29+
type InputArray = realndarray | genericndarray<number|string>;
3030

3131
/**
3232
* Sort order.
3333
*/
34-
type SortOrder = typedndarray<DataType> | number | string;
34+
type SortOrder = typedndarray<number> | genericndarray<number> | number | 'descending' | 'desc' | 'ascending' | 'asc';
3535

3636

3737
/**
@@ -51,6 +51,15 @@ interface Sorthp {
5151
/**
5252
* Sorts an input ndarray along one or more ndarray dimensions using heapsort.
5353
*
54+
* ## Notes
55+
*
56+
* - The input ndarray is sorted **in-place** (i.e., the input ndarray is **mutated**).
57+
* - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
58+
* - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
59+
* - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
60+
* - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
61+
* - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values).
62+
*
5463
* @param x - input ndarray
5564
* @param options - function options
5665
* @returns output ndarray
@@ -67,11 +76,20 @@ interface Sorthp {
6776
* var arr = ndarray2array( y );
6877
* // returns [ -3.0, -1.0, 2.0 ]
6978
*/
70-
<T = unknown, U extends InputArray<T> = InputArray<T>>( x: U, options?: Options ): U;
79+
<T extends InputArray = InputArray>( x: T, options?: Options ): T;
7180

7281
/**
7382
* Sorts an input ndarray along one or more ndarray dimensions using heapsort.
7483
*
84+
* ## Notes
85+
*
86+
* - The input ndarray is sorted **in-place** (i.e., the input ndarray is **mutated**).
87+
* - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
88+
* - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
89+
* - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
90+
* - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
91+
* - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values).
92+
*
7593
* @param x - input ndarray
7694
* @param sortOrder - sort order
7795
* @param options - function options
@@ -89,12 +107,21 @@ interface Sorthp {
89107
* var arr = ndarray2array( y );
90108
* // returns [ -3.0, -1.0, 2.0 ]
91109
*/
92-
<T = unknown, U extends InputArray<T> = InputArray<T>>( x: U, sortOrder: SortOrder, options?: Options ): U;
110+
<T extends InputArray = InputArray>( x: T, sortOrder: SortOrder, options?: Options ): T;
93111
}
94112

95113
/**
96114
* Sorts an input ndarray along one or more ndarray dimensions using heapsort.
97115
*
116+
* ## Notes
117+
*
118+
* - The input ndarray is sorted **in-place** (i.e., the input ndarray is **mutated**).
119+
* - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
120+
* - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
121+
* - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
122+
* - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
123+
* - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values).
124+
*
98125
* @param x - input ndarray
99126
* @param sortOrder - sort order
100127
* @param options - function options
@@ -111,6 +138,18 @@ interface Sorthp {
111138
*
112139
* var arr = ndarray2array( y );
113140
* // returns [ -3.0, -1.0, 2.0 ]
141+
*
142+
* @example
143+
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
144+
* var array = require( '@stdlib/ndarray/array' );
145+
*
146+
* var x = array( [ -1.0, 2.0, -3.0 ] );
147+
*
148+
* var y = sorthp( x, 1.0 );
149+
* // returns <ndarray>
150+
*
151+
* var arr = ndarray2array( y );
152+
* // returns [ -3.0, -1.0, 2.0 ]
114153
*/
115154
declare const sorthp: Sorthp;
116155

lib/node_modules/@stdlib/blas/ext/sorthp/docs/types/test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
/* eslint-disable @typescript-eslint/no-unused-expressions, space-in-parens */
19+
/* eslint-disable space-in-parens */
2020

2121
/// <reference types="@stdlib/types"/>
2222

@@ -77,7 +77,7 @@ import sorthp = require( './index' );
7777
sorthp( ( x: number ): number => x, 1.0, {} ); // $ExpectError
7878
}
7979

80-
// The compiler throws an error if the function is provided a sort order argument which is not an ndarray or scalar value...
80+
// The compiler throws an error if the function is provided a sort order argument which is not an ndarray, supported string literal, or scalar value...
8181
{
8282
const x = zeros( [ 2, 2 ], {
8383
'dtype': 'float64'
@@ -88,9 +88,13 @@ import sorthp = require( './index' );
8888
sorthp( x, [] ); // $ExpectError
8989
sorthp( x, ( x: number ): number => x ); // $ExpectError
9090

91+
sorthp( x, 'foo', {} ); // $ExpectError
9192
sorthp( x, true, {} ); // $ExpectError
9293
sorthp( x, false, {} ); // $ExpectError
94+
sorthp( x, null, {} ); // $ExpectError
95+
sorthp( x, void 0, {} ); // $ExpectError
9396
sorthp( x, [], {} ); // $ExpectError
97+
sorthp( x, {}, {} ); // $ExpectError
9498
sorthp( x, ( x: number ): number => x, {} ); // $ExpectError
9599
}
96100

lib/node_modules/@stdlib/blas/ext/sorthp/lib/base.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ var factory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory'
2929

3030
// VARIABLES //
3131

32-
var idtypes0 = dtypes( 'numeric_and_generic' ); // input ndarray
32+
var idtypes0 = dtypes( 'real_and_generic' ); // input ndarray
3333
var idtypes1 = dtypes( 'real_and_generic' ); // sortOrder ndarray
34-
var odtypes = dtypes( 'numeric_and_generic' );
34+
var odtypes = dtypes( 'real_and_generic' );
3535
var table = {
3636
'types': [
3737
'float64', // input/output
3838
'float32' // input/output
39-
40-
// FIXME: add specialized support for `csorthp` and `zsorthp` once the corresponding packages are implemented
4139
],
4240
'fcns': [
4341
dsorthp,

0 commit comments

Comments
 (0)