Skip to content

Commit 96551fd

Browse files
committed
Auto-generated commit
1 parent f2fe585 commit 96551fd

File tree

9 files changed

+18
-16
lines changed

9 files changed

+18
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,7 @@
12571257

12581258
### Bug Fixes
12591259

1260+
- [`3af0a04`](https://github.com/stdlib-js/stdlib/commit/3af0a041f6ae95c251cbfa2acae82b30e3b4579b) - return `NaN` when the number of indexed elements is zero in `stats/strided/distances/dcosine-similarity` [(#9497)](https://github.com/stdlib-js/stdlib/pull/9497)
12601261
- [`bda1a5c`](https://github.com/stdlib-js/stdlib/commit/bda1a5c6cfa6777839ab5f941296b2008880b75a) - use correct types
12611262
- [`20d29ed`](https://github.com/stdlib-js/stdlib/commit/20d29ed3410f2ff8ff6bfadbfb0a1f5a4b7e5fde) - use `int8ndarray` type for alternative hypothesis param in `ndarray/sztest` and `ndarray/dztest`
12621263
- [`0d71e53`](https://github.com/stdlib-js/stdlib/commit/0d71e530c42bc8d7c98ad779e505fc01bd904a1f) - ensure correct `this` context when creating a new Module instance
@@ -3551,6 +3552,7 @@ A total of 562 issues were closed in this release:
35513552

35523553
<details>
35533554

3555+
- [`3af0a04`](https://github.com/stdlib-js/stdlib/commit/3af0a041f6ae95c251cbfa2acae82b30e3b4579b) - **fix:** return `NaN` when the number of indexed elements is zero in `stats/strided/distances/dcosine-similarity` [(#9497)](https://github.com/stdlib-js/stdlib/pull/9497) _(by Nakul Krishnakumar)_
35543556
- [`c216b80`](https://github.com/stdlib-js/stdlib/commit/c216b80baf3efe0d21387a280368c44122328b76) - **feat:** add `stats/base/ndarray/smskmidrange` [(#9519)](https://github.com/stdlib-js/stdlib/pull/9519) _(by Sachin Pangal, Athan Reines)_
35553557
- [`bda1a5c`](https://github.com/stdlib-js/stdlib/commit/bda1a5c6cfa6777839ab5f941296b2008880b75a) - **fix:** use correct types _(by Athan Reines)_
35563558
- [`d681872`](https://github.com/stdlib-js/stdlib/commit/d681872a9b87321f4f66852f5aabfeec19e195fc) - **feat:** add `stats/base/ndarray/mskmidrange` [(#9511)](https://github.com/stdlib-js/stdlib/pull/9511) _(by Sachin Pangal)_

strided/distances/dcosine-similarity/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var z = dcosineSimilarity.ndarray( 3, x, 2, 1, y, -1, y.length-1 );
140140

141141
## Notes
142142

143-
- If `N <= 0`, both functions return `0.0`.
143+
- If `N <= 0`, both functions return `NaN`.
144144

145145
</section>
146146

strided/distances/dcosine-similarity/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Indexing is relative to the first index. To introduce an offset, use a typed
1010
array view.
1111

12-
If `N <= 0`, the function returns `0`.
12+
If `N <= 0`, the function returns `NaN`.
1313

1414
Parameters
1515
----------

strided/distances/dcosine-similarity/lib/ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function dcosineSimilarity( N, x, strideX, offsetX, y, strideY, offsetY ) {
5353
var dot;
5454

5555
if ( N <= 0 ) {
56-
return 0.0;
56+
return NaN;
5757
}
5858
dot = ddot( N, x, strideX, offsetX, y, strideY, offsetY );
5959
xnrm = dnrm2( N, x, strideX, offsetX );

strided/distances/dcosine-similarity/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ double API_SUFFIX( stdlib_strided_dcosine_similarity_ndarray )( const CBLAS_INT
5656
double dot;
5757

5858
if ( N <= 0 ) {
59-
return 0.0;
59+
return 0.0 / 0.0;
6060
}
6161
dot = c_ddot_ndarray( N, X, strideX, offsetX, Y, strideY, offsetY );
6262
xnrm = c_dnrm2_ndarray( N, X, strideX, offsetX );

strided/distances/dcosine-similarity/test/test.dcosine_similarity.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ tape( 'the function calculates the cosine similarity of two strided arrays', fun
6161
t.end();
6262
});
6363

64-
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) {
64+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) {
6565
var sim;
6666
var x;
6767
var y;
@@ -70,10 +70,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
7070
y = new Float64Array( [ 1.0, -2.0, 3.0 ] );
7171

7272
sim = dcosineSimilarity( 0, x, 1, y, 1 );
73-
t.strictEqual( isAlmostSameValue( sim, 0.0, 1 ), true, 'returns expected value' );
73+
t.strictEqual( isAlmostSameValue( sim, NaN, 1 ), true, 'returns expected value' );
7474

7575
sim = dcosineSimilarity( -4, x, 1, y, 1 );
76-
t.strictEqual( isAlmostSameValue( sim, 0.0, 1 ), true, 'returns expected value' );
76+
t.strictEqual( isAlmostSameValue( sim, NaN, 1 ), true, 'returns expected value' );
7777
t.end();
7878
});
7979

strided/distances/dcosine-similarity/test/test.dcosine_similarity.native.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ tape( 'the function calculates the cosine similarity of two strided arrays', opt
7070
t.end();
7171
});
7272

73-
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) {
73+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', opts, function test( t ) {
7474
var sim;
7575
var x;
7676
var y;
@@ -80,11 +80,11 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
8080

8181
// Test against textbook algorithm for computing cosine similarity:
8282
sim = dcosineSimilarity( 0, x, 1, y, 1 );
83-
t.strictEqual( isAlmostSameValue( sim, 0.0, 1 ), true, 'returns expected value' );
83+
t.strictEqual( isAlmostSameValue( sim, NaN, 1 ), true, 'returns expected value' );
8484

8585
// Test against textbook algorithm for computing cosine similarity:
8686
sim = dcosineSimilarity( -4, x, 1, y, 1 );
87-
t.strictEqual( isAlmostSameValue( sim, 0.0, 1 ), true, 'returns expected value' );
87+
t.strictEqual( isAlmostSameValue( sim, NaN, 1 ), true, 'returns expected value' );
8888
t.end();
8989
});
9090

strided/distances/dcosine-similarity/test/test.ndarray.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ tape( 'the function calculates the cosine similarity of two strided arrays', fun
6161
t.end();
6262
});
6363

64-
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) {
64+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) {
6565
var sim;
6666
var x;
6767
var y;
@@ -71,11 +71,11 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
7171

7272
// Test against textbook algorithm for computing cosine similarity:
7373
sim = dcosineSimilarity( 0, x, 1, 0, y, 1, 0 );
74-
t.strictEqual( isAlmostSameValue( sim, 0.0, 1 ), true, 'returns expected value' );
74+
t.strictEqual( isAlmostSameValue( sim, NaN, 1 ), true, 'returns expected value' );
7575

7676
// Test against textbook algorithm for computing cosine similarity:
7777
sim = dcosineSimilarity( -4, x, 1, 0, y, 1, 0 );
78-
t.strictEqual( isAlmostSameValue( sim, 0.0, 1 ), true, 'returns expected value' );
78+
t.strictEqual( isAlmostSameValue( sim, NaN, 1 ), true, 'returns expected value' );
7979
t.end();
8080
});
8181

strided/distances/dcosine-similarity/test/test.ndarray.native.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ tape( 'the function calculates the cosine similarity of two strided arrays', opt
7070
t.end();
7171
});
7272

73-
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) {
73+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', opts, function test( t ) {
7474
var sim;
7575
var x;
7676
var y;
@@ -80,11 +80,11 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
8080

8181
// Test against textbook algorithm for computing cosine similarity:
8282
sim = dcosineSimilarity( 0, x, 1, 0, y, 1, 0 );
83-
t.strictEqual( isAlmostSameValue( sim, 0.0, 1 ), true, 'returns expected value' );
83+
t.strictEqual( isAlmostSameValue( sim, NaN, 1 ), true, 'returns expected value' );
8484

8585
// Test against textbook algorithm for computing cosine similarity:
8686
sim = dcosineSimilarity( -4, x, 1, 0, y, 1, 0 );
87-
t.strictEqual( isAlmostSameValue( sim, 0.0, 1 ), true, 'returns expected value' );
87+
t.strictEqual( isAlmostSameValue( sim, NaN, 1 ), true, 'returns expected value' );
8888
t.end();
8989
});
9090

0 commit comments

Comments
 (0)