Skip to content

Commit 6f1e997

Browse files
committed
Auto-generated commit
1 parent 02b63bf commit 6f1e997

File tree

14 files changed

+17841
-2
lines changed

14 files changed

+17841
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-04-01)
7+
## Unreleased (2025-04-02)
88

99
<section class="packages">
1010

@@ -1334,6 +1334,7 @@ A total of 9 people contributed to this release. Thank you to the following cont
13341334

13351335
<details>
13361336

1337+
- [`b96a6a2`](https://github.com/stdlib-js/stdlib/commit/b96a6a258f9c560073e252b9969095a12723074e) - **test:** add missing tests to `ndarray/base/unary` [(#5821)](https://github.com/stdlib-js/stdlib/pull/5821) _(by Muhammad Haris)_
13371338
- [`998b3ba`](https://github.com/stdlib-js/stdlib/commit/998b3ba4e628e6d8564c6b33fe41925da2046b41) - **feat:** add missing kernels to `ndarray/base/unary-reduce-subarray` [(#6421)](https://github.com/stdlib-js/stdlib/pull/6421) _(by Muhammad Haris)_
13381339
- [`89d16f9`](https://github.com/stdlib-js/stdlib/commit/89d16f95b188c5afb513af630134dd40cdad380b) - **chore:** fix JSON lint errors [(#6466)](https://github.com/stdlib-js/stdlib/pull/6466) _(by Sai Avinash)_
13391340
- [`f0af2cb`](https://github.com/stdlib-js/stdlib/commit/f0af2cb05b0442f2ef20f5296cee2576191130e8) - **chore:** fix JavaScript lint errors [(#6463)](https://github.com/stdlib-js/stdlib/pull/6463) _(by lohithganni)_

base/unary/test/test.0d.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var tape = require( 'tape' );
24+
var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' );
25+
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
26+
var Complex128Array = require( '@stdlib/array/complex128' );
27+
var Float64Array = require( '@stdlib/array/float64' );
28+
var Complex128 = require( '@stdlib/complex/float64/ctor' );
29+
var real = require( '@stdlib/complex/float64/real' );
30+
var imag = require( '@stdlib/complex/float64/imag' );
31+
var scalar2ndarray = require( './../../../from-scalar' );
32+
var unary = require( './../lib' );
33+
34+
35+
// TESTS //
36+
37+
tape( 'main export is a function', function test( t ) {
38+
t.ok( true, __filename );
39+
t.strictEqual( typeof unary, 'function', 'main export is a function');
40+
t.end();
41+
});
42+
43+
tape( 'the function applies a unary callback to each indexed element of a 0-dimensional ndarray', function test( t ) {
44+
var expected;
45+
var x;
46+
var y;
47+
48+
x = scalar2ndarray( 5.0, {
49+
'dtype': 'float64'
50+
});
51+
52+
y = scalar2ndarray( 0.0, {
53+
'dtype': 'float64'
54+
});
55+
56+
unary( [ x, y ], scale );
57+
58+
expected = new Float64Array( [ 50.0 ] );
59+
t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' );
60+
t.end();
61+
62+
function scale( x ) {
63+
return x * 10.0;
64+
}
65+
});
66+
67+
tape( 'the function applies a unary callback to each indexed element of a 0-dimensional ndarray (accessors)', function test( t ) {
68+
var expected;
69+
var x;
70+
var y;
71+
72+
x = scalar2ndarray( new Complex128( 5.0, 5.0 ), {
73+
'dtype': 'complex128'
74+
});
75+
76+
y = scalar2ndarray( new Complex128( 0.0, 0.0 ), {
77+
'dtype': 'complex128'
78+
});
79+
80+
unary( [ x, y ], scale );
81+
82+
expected = new Complex128Array( [ 50.0, 50.0 ] );
83+
t.strictEqual( isSameComplex128Array( y.data, expected ), true, 'returns expected value' );
84+
t.end();
85+
86+
function scale( z ) {
87+
return new Complex128( real(z)*10.0, imag(z)*10.0 );
88+
}
89+
});

0 commit comments

Comments
 (0)