refactor: fix inconsistencies across packages in blas/ext/base* - #15146
refactor: fix inconsistencies across packages in blas/ext/base*#15146headlessNode wants to merge 68 commits into
blas/ext/base*#15146Conversation
|
@kgryte This ended up being a lot bigger than I expected. The 'fixes' are mostly docs and tests related. I will updated the currently open related PR's as well. |
Coverage Report
The above coverage report was generated for the changes in this PR. |
12c993b to
bce0dee
Compare
---
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_pkg_readmes
status: passed
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: passed
- 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: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: missing_dependencies
- 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
---
---
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_pkg_readmes
status: passed
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: na
- 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
---
|
Expected benchmarks lint error due to time-out. |
| A complex number is truthy when at least one of its real or imaginary | ||
| components is truthy. | ||
|
|
||
| If unable to find a truthy element, the function returns `-1`. |
There was a problem hiding this comment.
@headlessNode What is the rationale for removing this note?
There was a problem hiding this comment.
I see it is not present in, say, cindex-of.
There was a problem hiding this comment.
Yeah I used index-of family as canon for docs related changes. Except a few places.
There was a problem hiding this comment.
Yes, I suppose that makes sense. Although, we should be careful, as these specializations should be allowed to have API-specific notes, where appropriate.
| A complex number is truthy when at least one of its real or imaginary | ||
| components is truthy. | ||
|
|
||
| If unable to find a truthy element, the function returns `-1`. |
| > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0 ] ); | ||
| > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); | ||
| > idx = {{alias}}( 2, x1, 1, y1, 1 ) | ||
| > var idx = {{alias}}( 2, x1, 1, y1, 1 ) |
There was a problem hiding this comment.
| > var idx = {{alias}}( 2, x1, 1, y1, 1 ) | |
| > idx = {{alias}}( 2, x1, 1, y1, 1 ) |
This isn't correct. You've already declared idx at L42 above.
| -1 | ||
| > var y0 = new {{alias:@stdlib/array/float64}}( [ 9.0, 9.0, 0.0, 9.0 ] ); | ||
| > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); | ||
| > var idx = {{alias}}( 2, x1, 1, y1, 1 ) |
There was a problem hiding this comment.
| > var idx = {{alias}}( 2, x1, 1, y1, 1 ) | |
| > idx = {{alias}}( 2, x1, 1, y1, 1 ) |
Same comment. You should go back through and ensure we are not redeclaring in these files.
| var x; | ||
| var y; | ||
|
|
||
| x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); |
There was a problem hiding this comment.
Why are we refactoring to inline here? The test cases are simpler when you use separate variables x and y here.
| y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); | ||
|
|
||
| actual = dfirstIndexLessThan( 0, x, 1, y, 1 ); | ||
| actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); |
| y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); | ||
|
|
||
| actual = dfirstIndexLessThan( 0, x, 1, 0, y, 1, 0 ); | ||
| actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); |
| y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); | ||
|
|
||
| actual = dfirstIndexLessThan( 0, x, 1, 0, y, 1, 0 ); | ||
| actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); |
| > var idx = {{alias}}( 3, x, 2 ) | ||
| 1 | ||
|
|
||
| // Using view offsets: | ||
| > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); | ||
| > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); | ||
| > var idx = {{alias}}( 3, x1, 2 ) |
There was a problem hiding this comment.
| > var idx = {{alias}}( 3, x, 2 ) | |
| 1 | |
| // Using view offsets: | |
| > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); | |
| > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); | |
| > var idx = {{alias}}( 3, x1, 2 ) | |
| > idx = {{alias}}( 3, x, 2 ) | |
| 1 | |
| // Using view offsets: | |
| > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); | |
| > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); | |
| > idx = {{alias}}( 3, x1, 2 ) |
Incorrect. Do not redeclare.
|
|
||
| // Using an index offset: | ||
| > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); | ||
| > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) |
There was a problem hiding this comment.
| > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) | |
| > idx = {{alias}}.ndarray( 3, x, 2, 1 ) |
| // Negative stride... | ||
| actual = dindexOfFalsy( x.length, x, -1 ); | ||
| t.strictEqual( actual, 1, 'returns expected value' ); | ||
| tape( 'the function ignores truthy elements (e.g., non-zero values)', function test( t ) { |
There was a problem hiding this comment.
How is this test materially different than the one above?
There was a problem hiding this comment.
I am not convinced it adds anything.
| // Negative stride... | ||
| actual = dindexOfFalsy( x.length, x, -1 ); | ||
| t.strictEqual( actual, 1, 'returns expected value' ); | ||
| tape( 'the function ignores truthy elements (e.g., non-zero values)', opts, function test( t ) { |
There was a problem hiding this comment.
Same question in this and other test files.
| @@ -42,7 +42,7 @@ | |||
| > var idx = {{alias}}( 3, 1.0, x, 2 ) | |||
There was a problem hiding this comment.
| > var idx = {{alias}}( 3, 1.0, x, 2 ) | |
| > idx = {{alias}}( 3, 1.0, x, 2 ) |
| // Using view offsets: | ||
| > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 1.0, 1.0 ] ); | ||
| > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); | ||
| > var idx = {{alias}}( 2, 1.0, x1, 1 ) |
There was a problem hiding this comment.
| > var idx = {{alias}}( 2, 1.0, x1, 1 ) | |
| > idx = {{alias}}( 2, 1.0, x1, 1 ) |
| alternative indexing semantics. | ||
|
|
||
| While typed array views mandate a view offset based on the underlying | ||
| buffer, the offset parameter supports indexing semantics based on a |
| // Advanced indexing: | ||
| // Using an index offset: | ||
| > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 1.0, 3.0, 1.0, 4.0 ] ); | ||
| > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) |
There was a problem hiding this comment.
| > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) | |
| > idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) |
kgryte
left a comment
There was a problem hiding this comment.
Left initial comments. Still some clean-up to do.
Resolves stdlib-js/metr-issue-tracker#1316.
Description
This pull request:
blas/ext/base*Related Issues
This pull request has the following related issues:
blas/ext/base*metr-issue-tracker#1316.Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
Primarily written by Claude Code.
@stdlib-js/reviewers