stdlib
stdlib copied to clipboard
[RFC]: add tests for `@stdlib/ndarray/base/nullary`
Description
Currently, the @stdlib/ndarray/base/nullary/test/test.js
only tests whether the main export is a function.
This RFC proposes to add tests to verify:
-
The first argument provided is an ndarray-like object
-
The input ndarray-like object contains valid
data
,dtype
,shape
,stride
,offset
, andorder
properties -
No modification occurs if the
data
property of the input ndarray-like object is empty -
The second argument provided is a function
-
The second argument returns a value compatible with the
dtype
of the output ndarray -
The
nullary
function returns void
Related Issues
No.
Questions
No.
Other
No.
Checklist
- [X] I have read and understood the Code of Conduct.
- [X] Searched for existing issues and pull requests.
- [X] The issue name begins with
RFC:
.
:wave: Hi there! :wave:
And thank you for opening your first issue! We will get back to you shortly. :runner: :dash:
@kgryte @Planeshifter @Pranavchiku I'd like to work on this issue.
@headlessNode Thanks for opening this issue. Tests would be good to add for @stdlib/ndarray/base/nullary
, so this contribution would be welcome.
I would suggest, however, consulting @stdlib/strided/base/nullary
to see how tests are done there, as @stdlib/ndarray/base/nullary
is the ndarray
analog to that package.
Of note, several of the verifications you mention are not necessary, such as verifying that an ndarray-like object is provided, that a function is provided, that the ndarray-like object has specified properties, etc. @stdlib/ndarray/base/nullary
is a "base" package, and we assume that a user knows what they are doing and has provided valid arguments, as can be observed from the implementation of @stdlib/ndarray/base/nullary
.
Instead, tests should verify iteration behavior for 0-11D ndarrays, including contiguous and non-contiguous views, etc. Additionally, tests should verify iteration behavior for ndarrays backed by accessor arrays (e.g., ndarrays have a complex-valued data type, such as complex64
or complex128
).
Doing all this will be required in order to achieve 100% test coverage for this package, given its implementation: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/nullary/lib
@kgryte I have gone through the @stdlib/strided/base/nullary
and understand the "pattern" used there for testing. From my understanding, I would need to import
the nullary0d
up to nd
and perform testing for each, including the tests for complex data types.
However, I noticed that I'm not assigned to this issue. I'd like to be assigned the issue to work on it.
@headlessNode Assigned.
Cross-linking https://github.com/stdlib-js/stdlib/pull/2350#pullrequestreview-2176587352 and copying over comment:
The primary missing tests needed at this point to achieve full test coverage are for blocked iteration. I've added tests for 2D blocked iteration.
Full test coverage can be achieved by extending the strategy for 2D blocked iteration to higher dimensions, utilizing (and shuffling around) singleton dimensions to exercise isolated conditionals at each nested loop level.
@kgryte can I go ahead and work on adding the tests for higher dimensions?
@headlessNode Sure! See the "large arrays" tests for 2D for the idea.
@kgryte Great. One more thing, why work on these in a new PR? I mean I could've added these in the PR we were working on.
@headlessNode No reason other than wanting to get something in. Some tests are better than no tests. And easier to review if the changes are isolated.
@kgryte Makes sense. Thanks for the clarification.