feat!: add writable parameter to ndarray/base/remove-singleton-dimensions#9667
feat!: add writable parameter to ndarray/base/remove-singleton-dimensions#9667kgryte merged 6 commits intostdlib-js:developfrom
ndarray/base/remove-singleton-dimensions#9667Conversation
---
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: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- 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: 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: passed
- task: lint_license_headers
status: passed
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
ndarray/base/remove-singleton-dimensionsndarray/base/remove-singleton-dimensions
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
| The function accepts the following arguments: | ||
|
|
||
| - **x**: input ndarray. | ||
| - **writable**: boolean indicating whether a returned ndarray should be writable. |
There was a problem hiding this comment.
This parameter is somewhat in conflict with the note at L74. Namely, if we return a provided ndarray unchanged, then the writable parameter is ignored.
There was a problem hiding this comment.
We have a couple of choices. 1) Always return a new view of the input ndarray. 2) Update the docs here to indicate that the writable parameter will be ignored if the input ndarray doesn't have any singleton dimensions. 3) Pursue (1) plus add the package maybe-remove-singleton-dimensions where this new package does what this package does now, which is returns an input ndarray unchanged iff an input ndarray has no singleton dimensions.
The original rationale for sometimes returning the original input ndarray is for performance, as ndarray view creation is expensive. Having a maybe-* prefix makes this behavior explicit similar to maybe-broadcast-array, etc.
That seem reasonable to you, @headlessNode?
There was a problem hiding this comment.
@kgryte So, we add a maybe- prefix to this package and add the remove-singleton-dimensions package which always return a new view?
There was a problem hiding this comment.
@headlessNode That doesn't quite make sense. It means copy the current package to maybe-* and then modify the existing package to always return a view.
There was a problem hiding this comment.
Also means that we'll need a follow-up PR to migrate all current downstream usage to use the maybe-* package.
There was a problem hiding this comment.
@kgryte I've modified the current package to always return a new view. I think adding the maybe-* package and updating downstream usage should be separate PR?
There was a problem hiding this comment.
Correct. Adding and updating should actually be two separate PRs (in addition to the current PR).
|
For METR, initial review |
---
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: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- 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: 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: passed
- 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
status: passed
- task: lint_package_json
status: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- 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: passed
- 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
status: passed
- task: lint_package_json
status: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- 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: passed
- task: lint_license_headers
status: passed
---
kgryte
left a comment
There was a problem hiding this comment.
LGTM after some minor clean-up.
|
For METR, |
|
@headlessNode You can go ahead and create the METR RFC for creating the package as discussed in the comment discussion above. |
…sions` This commit adds support for a writable parameter. Previously, we'd return a writable ndarray if a provided ndarray was writable, and a read-only ndarray if a provided ndarray was read-only. This is now configurable. Additionally, this commit changes behavior such that a new view is always returned. Previously, if an input ndarray did not contain singleton dimensions, we'd always return the input ndarray. That is no longer the case. BREAKING CHANGE: add writable parameter and always return a new view To migrate, in order to preserve prior writable behavior, users should set the final parameter equal to a boolean indicating whether the input ndarray is writable. If not, pass `false`; if yes, pass `true`. To preserve prior behavior in which the input ndarray is returned if it does not have singleton dimensions, use `ndarray/base/maybe-remove-singleton-dimensions`. PR-URL: stdlib-js#9667 Closes: stdlib-js/metr-issue-tracker#151 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves stdlib-js/metr-issue-tracker#151.
Description
This pull request:
ndarray/base/remove-singleton-dimensionsRelated Issues
This pull request has the following related issues:
ndarray/base/remove-singleton-dimensionsmetr-issue-tracker#151Questions
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