Repository navigation
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
0PrashantYadav0
left a comment
There was a problem hiding this comment.
Tracking issue #14034 marks the ztest family as blocked on custom-dtype support (the note was added after this PR was opened), and this PR works around that with y.get().toDataView(), as stats/strided/sztest does, so a maintainer needs to confirm the approach. The AI disclosure in the description is still {{TODO: add disclosure if applicable}}.
| var x = arrays[ 0 ]; | ||
| var y = arrays[ 1 ]; | ||
|
|
||
| addon( getData( x ), serialize( x ), getData( alt ), serialize( alt ), getData( alpha ), serialize( alpha ), getData( mu ), serialize( mu ), getData( sigma ), serialize( sigma ), y.get().toDataView() ); // eslint-disable-line max-len |
There was a problem hiding this comment.
When the output ndarray has a non-zero offset, the native path writes to the wrong struct. With buf = new ResultsArray( 3 ) and out = new ndarray( Float32Results, buf, [], [ 0 ], 1, 'row-major' ), main.js fills buf.get( 1 ) but native.js fills buf.get( 2 ). With offset 2, it writes past the end of the buffer.
The cause is upstream. At napi/argv-dataview/src/main.c:69, the code adds byte_offset to a pointer that napi_get_dataview_info has already offset. stats/strided/sztest native has the same bug with buf.get( 1 ). Should this wait for that fix, and then add an output-offset case to test/test.native.js?
| static double rand_double( void ) { | ||
| return (double)rand() / ( (double)RAND_MAX + 1.0 ); |
There was a problem hiding this comment.
| static double rand_double( void ) { | |
| return (double)rand() / ( (double)RAND_MAX + 1.0 ); | |
| static float rand_float( void ) { | |
| int r = rand(); | |
| return (float)r / ( (float)RAND_MAX + 1.0f ); |
Also update line 133 to data[ i ] = ( rand_float()*10.0f ) - 5.0f;. Same as #15170 (comment).
Resolves a part of #14034
Description
This pull request:
Related Issues
This pull request has the following related issues:
@stdlib/stats/base/ndarraypackages (tracking issue) #14034Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
{{TODO: add disclosure if applicable}}
@stdlib-js/reviewers