Skip to content

Commit 1a92a74

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: passed - 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: passed - 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 4eeada0 commit 1a92a74

File tree

9 files changed

+148
-101
lines changed

9 files changed

+148
-101
lines changed

lib/node_modules/@stdlib/ndarray/base/to-transposed/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ limitations under the License.
1818
1919
-->
2020

21-
# to-transposed
21+
# toTransposed
2222

23-
> Return a new transposed ndarray.
23+
> Return a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -42,7 +42,7 @@ var toTransposed = require( '@stdlib/ndarray/base/to-transposed' );
4242

4343
#### toTransposed( x )
4444

45-
Returns a new transposed ndarray.
45+
Returns a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.
4646

4747
```javascript
4848
var array = require( '@stdlib/ndarray/array' );
@@ -66,6 +66,10 @@ The function accepts the following arguments:
6666

6767
<section class="notes">
6868

69+
## Notes
70+
71+
- If provided an ndarray with fewer than two dimensions, the function raises an exception.
72+
6973
</section>
7074

7175
<!-- /.notes -->

lib/node_modules/@stdlib/ndarray/base/to-transposed/benchmark/benchmark.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ bench( format( '%s::2d,non-base', pkg ), function benchmark( b ) {
6464
var v;
6565
var i;
6666

67-
/* eslint-disable object-curly-newline */
67+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
6868

6969
values = [
70-
empty( [ 2, 2 ], { 'dtype': 'float64' }),
71-
empty( [ 2, 2 ], { 'dtype': 'float32' }),
72-
empty( [ 2, 2 ], { 'dtype': 'int32' }),
73-
empty( [ 2, 2 ], { 'dtype': 'complex128' }),
74-
empty( [ 2, 2 ], { 'dtype': 'generic' })
70+
empty( [ 2, 2 ], { 'dtype': 'float64' } ),
71+
empty( [ 2, 2 ], { 'dtype': 'float32' } ),
72+
empty( [ 2, 2 ], { 'dtype': 'int32' } ),
73+
empty( [ 2, 2 ], { 'dtype': 'complex128' } ),
74+
empty( [ 2, 2 ], { 'dtype': 'generic' } )
7575
];
7676

77-
/* eslint-enable object-curly-newline */
77+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
7878

7979
b.tic();
8080
for ( i = 0; i < b.iterations; i++ ) {
@@ -124,17 +124,17 @@ bench( format( '%s::3d,non-base', pkg ), function benchmark( b ) {
124124
var v;
125125
var i;
126126

127-
/* eslint-disable object-curly-newline */
127+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
128128

129129
values = [
130-
empty( [ 2, 2, 2 ], { 'dtype': 'float64' }),
131-
empty( [ 2, 2, 2 ], { 'dtype': 'float32' }),
132-
empty( [ 2, 2, 2 ], { 'dtype': 'int32' }),
133-
empty( [ 2, 2, 2 ], { 'dtype': 'complex128' }),
134-
empty( [ 2, 2, 2 ], { 'dtype': 'generic' })
130+
empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ),
131+
empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ),
132+
empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ),
133+
empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ),
134+
empty( [ 2, 2, 2 ], { 'dtype': 'generic' } )
135135
];
136136

137-
/* eslint-enable object-curly-newline */
137+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
138138

139139
b.tic();
140140
for ( i = 0; i < b.iterations; i++ ) {
@@ -184,17 +184,17 @@ bench( format( '%s::4d,non-base', pkg ), function benchmark( b ) {
184184
var v;
185185
var i;
186186

187-
/* eslint-disable object-curly-newline */
187+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
188188

189189
values = [
190-
empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' }),
191-
empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' }),
192-
empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' }),
193-
empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' }),
194-
empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' })
190+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
191+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
192+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
193+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
194+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } )
195195
];
196196

197-
/* eslint-enable object-curly-newline */
197+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
198198

199199
b.tic();
200200
for ( i = 0; i < b.iterations; i++ ) {
@@ -244,17 +244,17 @@ bench( format( '%s::5d,non-base', pkg ), function benchmark( b ) {
244244
var v;
245245
var i;
246246

247-
/* eslint-disable object-curly-newline */
247+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
248248

249249
values = [
250-
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' }),
251-
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' }),
252-
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' }),
253-
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' }),
254-
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' })
250+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
251+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
252+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
253+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
254+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } )
255255
];
256256

257-
/* eslint-enable object-curly-newline */
257+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
258258

259259
b.tic();
260260
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/ndarray/base/to-transposed/docs/repl.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
{{alias}}( x )
3-
Returns a new transposed ndarray.
3+
Returns a new ndarray containing the elements of an input ndarray but whose
4+
last two dimensions are transposed.
45

56
Parameters
67
----------

lib/node_modules/@stdlib/ndarray/base/to-transposed/docs/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import { ndarray } from '@stdlib/types/ndarray';
2424

2525
/**
26-
* Returns a new transposed ndarray.
26+
* Returns a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.
2727
*
2828
* @param x - input array
2929
* @returns output ndarray
@@ -37,7 +37,7 @@ import { ndarray } from '@stdlib/types/ndarray';
3737
* var out = toTransposed( x );
3838
* // returns <ndarray>[ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
3939
*/
40-
declare function toTransposed( x: ndarray ): ndarray;
40+
declare function toTransposed<T extends ndarray = ndarray>( x: T ): T;
4141

4242

4343
// EXPORTS //

lib/node_modules/@stdlib/ndarray/base/to-transposed/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import toTransposed = require( './index' );
2727
const sh = [ 2, 2 ];
2828
const ord = 'row-major';
2929

30-
toTransposed( zeros( 'float64', sh, ord ) ); // $ExpectType ndarray
30+
toTransposed( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray
3131
}
3232

3333
// The compiler throws an error if the function is provided a first argument which is not an ndarray...

lib/node_modules/@stdlib/ndarray/base/to-transposed/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Return a new transposed ndarray.
22+
* Return a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.
2323
*
2424
* @module @stdlib/ndarray/base/to-transposed
2525
*

lib/node_modules/@stdlib/ndarray/base/to-transposed/lib/main.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,18 @@
2020

2121
// MODULES //
2222

23-
var getDType = require( '@stdlib/ndarray/base/dtype' );
24-
var getShape = require( '@stdlib/ndarray/base/shape' );
25-
var getOrder = require( '@stdlib/ndarray/base/order' );
2623
var transpose = require( '@stdlib/ndarray/base/transpose' );
27-
var empty = require( '@stdlib/ndarray/base/empty' );
24+
var emptyLike = require( '@stdlib/ndarray/base/empty-like' );
2825
var assign = require( '@stdlib/ndarray/base/assign' );
2926

3027

3128
// MAIN //
3229

3330
/**
34-
* Returns a new transposed ndarray.
31+
* Returns a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.
3532
*
3633
* @param {ndarray} x - input array
34+
* @throws {Error} must provide an array with two or more dimensions
3735
* @returns {ndarray} output ndarray
3836
*
3937
* @example
@@ -48,18 +46,12 @@ var assign = require( '@stdlib/ndarray/base/assign' );
4846
function toTransposed( x ) {
4947
var view;
5048
var out;
51-
var tmp;
52-
var sh;
5349

5450
// Create transposed view of the input array:
5551
view = transpose( x, false );
5652

5753
// Create an output array:
58-
sh = getShape( x, true );
59-
tmp = sh[ sh.length-1 ];
60-
sh[ sh.length-1 ] = sh[ sh.length-2 ];
61-
sh[ sh.length-2 ] = tmp;
62-
out = empty( getDType( x ), sh, getOrder( x ) );
54+
out = emptyLike( view );
6355

6456
// Copy elements from transposed view to output array:
6557
assign( [ view, out ] );

lib/node_modules/@stdlib/ndarray/base/to-transposed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/ndarray/base/to-transposed",
33
"version": "0.0.0",
4-
"description": "Return a new transposed ndarray.",
4+
"description": "Return a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",

0 commit comments

Comments
 (0)