-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat!: add writable parameter to ndarray/base/remove-singleton-dimensions
#9667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
---
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 <[email protected]>
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/README.md
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <[email protected]>
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Adding and updating should actually be two separate PRs (in addition to the current PR).
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/benchmark/benchmark.ndims.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/docs/types/test.ts
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/docs/types/test.ts
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/examples/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/lib/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/lib/main.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/test/test.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/ndarray/base/remove-singleton-dimensions/test/test.js
Outdated
Show resolved
Hide resolved
kgryte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left initial comments.
kgryte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left initial comments.
|
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:
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