Skip to content

Commit 1936ee3

Browse files
committed
test: add tests and update docs
--- 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: na - 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: na - task: lint_license_headers status: passed ---
1 parent eb98874 commit 1936ee3

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

lib/node_modules/@stdlib/ndarray/concat/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var arr = ndarray2array( out );
6060

6161
The function accepts the following arguments:
6262

63-
- **arrays**: a list of input [ndarrays][@stdlib/ndarray/ctor]. Must be [broadcast compatible][@stdlib/ndarray/base/broadcast-shapes] except for the dimension along which to concatenate. The data type of the output [ndarray][@stdlib/ndarray/ctor] is determined by applying [type promotion rules][@stdlib/ndarray/promotion-rules] to the list of input [ndarrays][@stdlib/ndarray/ctor].
63+
- **arrays**: a list of input [ndarrays][@stdlib/ndarray/ctor]. Must be [broadcast compatible][@stdlib/ndarray/base/broadcast-shapes] except for the dimension along which to concatenate. The data type of the output [ndarray][@stdlib/ndarray/ctor] is determined by applying [type promotion rules][@stdlib/ndarray/promotion-rules] to the list of input [ndarrays][@stdlib/ndarray/ctor]. If provided [ndarrays][@stdlib/ndarray/ctor] having different [memory layouts][@stdlib/ndarray/orders], the output [ndarray][@stdlib/ndarray/ctor] has the [default order][@stdlib/ndarray/defaults].
6464
- **dim**: dimension along which to concatenate input [ndarrays][@stdlib/ndarray/ctor] (_optional_). Must be a negative integer. The index of the dimension along which to concatenate is resolved relative to the last dimension, with the last dimension corresponding to the value `-1`. Default: `-1`.
6565

6666
#### concat.assign( arrays, out\[, dim] )
@@ -161,6 +161,10 @@ console.log( ndarray2array( out ) );
161161

162162
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/dtypes
163163

164+
[@stdlib/ndarray/orders]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/orders
165+
166+
[@stdlib/ndarray/defaults]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/defaults
167+
164168
[@stdlib/ndarray/promotion-rules]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/promotion-rules
165169

166170
[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts

lib/node_modules/@stdlib/ndarray/concat/docs/repl.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
Parameters
66
----------
77
arrays: ArrayLikeObject<ndarray>
8-
Array-like object containing input ndarrays.
8+
List of ndarrays to concatenate. Must be broadcast compatible except for
9+
the dimension along which to concatenate. The data type of the output
10+
ndarray is determined by applying type promotion rules to the list of
11+
input ndarrays. If provided ndarrays having different memory layouts,
12+
the output ndarray has the default order.
913

1014
dim: integer (optional)
1115
Dimension along which to concatenate input ndarrays. Must be a negative
@@ -35,7 +39,10 @@
3539
Parameters
3640
----------
3741
arrays: ArrayLikeObject<ndarray>
38-
Array-like object containing input ndarrays.
42+
List of ndarrays to concatenate. Must be broadcast compatible except for
43+
the dimension along which to concatenate. Must promote] to a data type
44+
which can be (mostly) safely cast to the data type of the output
45+
ndarray.
3946

4047
out: ndarray
4148
Output ndarray.

lib/node_modules/@stdlib/ndarray/concat/test/test.main.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' );
2525
var ndarray = require( '@stdlib/ndarray/ctor' );
2626
var getShape = require( '@stdlib/ndarray/shape' );
2727
var getDType = require( '@stdlib/ndarray/dtype' );
28+
var getOrder = require( '@stdlib/ndarray/order' );
29+
var defaults = require( '@stdlib/ndarray/defaults' );
2830
var ndarray2array = require( '@stdlib/ndarray/to-array' );
2931
var Float64Array = require( '@stdlib/array/float64' );
3032
var Int32Array = require( '@stdlib/array/int32' );
@@ -333,6 +335,37 @@ tape( 'the function concatenates ndarrays along a specified dimension', function
333335
t.end();
334336
});
335337

338+
tape( 'the function concatenates ndarrays along a specified dimension (different orders)', function test( t ) {
339+
var expected;
340+
var actual;
341+
var xbuf;
342+
var ybuf;
343+
var out;
344+
var x;
345+
var y;
346+
347+
xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
348+
x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
349+
350+
ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] );
351+
y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 1, 2 ], 0, 'column-major' );
352+
353+
out = concat( [ x, y ] );
354+
355+
actual = ndarray2array( out );
356+
expected = [
357+
[ 1.0, 2.0, 5.0, 7.0, 9.0 ],
358+
[ 3.0, 4.0, 6.0, 8.0, 10.0 ]
359+
];
360+
361+
t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' );
362+
t.deepEqual( getShape( out ), [ 2, 5 ], 'returns expected value' );
363+
t.strictEqual( getOrder( out ), defaults.get( 'order' ), 'returns expected value' );
364+
t.deepEqual( actual, expected, 'returns expected value' );
365+
366+
t.end();
367+
});
368+
336369
tape( 'the function concatenates ndarrays along a specified dimension (type promotion)', function test( t ) {
337370
var expected;
338371
var actual;

0 commit comments

Comments
 (0)