You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Find one package containing inline NaN generation in a C source file (for example, 0.0/0.0) and update it according to this issue.
Follow all additional guidance in this issue.
Description
This RFC proposes replacing inline NaN generation (for example, 0.0/0.0 or 0.0f/0.0f) in C source files, examples, benchmarks and README C usage snippets with the stdlib NaN constant from @stdlib/constants/float64/nan or @stdlib/constants/float32/nan.
In short, this RFC seeks to refactor code from this pattern:
The migration is demonstrated in this PR commit fb7122c
In particular, notice three things:
We add the C header include for the NaN constant.
We replace inline NaN generation with STDLIB_CONSTANT_FLOAT64_NAN.
We add the dependency @stdlib/constants/float64/nan to manifest configuration entries which compile that same C source file (typically build, benchmark, and examples, when applicable).
By performing this refactoring, we facilitate:
Consistent NaN handling across packages and targets.
Better readability and maintainability in C implementations.
Note:
There are also inline Float32 NaN occurrences as 0.0f/0.0f which needs to be replaced by STDLIB_CONSTANT_FLOAT32_NAN from @stdlib/constants/float32/nan. Refer to this commit 767d45c for reference.
Steps
Given the relatively widespread use of inline NaN generation, this RFC is an open call for contributors to do the following:
Ensure your local development environment is set up by following the contributing guide
Find one package containing inline NaN generation in C source files.
Update that package, and only that package, to use STDLIB_CONSTANT_FLOAT64_NAN from @stdlib/constants/float64/nan.
Add the include statement for stdlib/constants/float64/nan.h in updated C sources.
Update the package manifest dependencies for all task configurations that compile the updated source file.
Build the Node add-on and run the example, test and benchmark C files using the following commands
General command patterns:
cd /home/stdlib
# Install all repo dependencies (only needed once after cloning)
make install
# Build the Node add-on for the specific package
make install-node-addons NODE_ADDONS_PATTERN="<package-path>"# Run C examples, benchmarks, native tests
make EXAMPLES_FILTER=".*/<package-path>/.*" examples-c
make BENCHMARKS_FILTER=".*/<package-path>/.*" benchmark-c
TEST_NATIVE=1 make test TESTS_FILTER=".*/<package-path>/.*"
For example, for stats/base/dists/normal/pdf:
cd /home/stdlib
# Install all repo dependencies (only needed once after cloning)
make install
# Build the Node add-on for the specific package
make install-node-addons NODE_ADDONS_PATTERN="stats/strided/dnanmeanpn"# Run C examples, benchmarks, native tests
make EXAMPLES_FILTER=".*/stats/strided/dnanmeanpn/.*" examples-c
make BENCHMARKS_FILTER=".*/stats/strided/dnanmeanpn/.*" benchmark-c
TEST_NATIVE=1 make test TESTS_FILTER=".*/stats/strided/dnanmeanpn/.*"
Commit your changes.
Submit a PR updating that package only.
Use this PR title template:
refactor: use constants/float64/nan in < package-name >
In the PR body, use the phrase Resolves a part of , and not Resolves or Closes, because this is a tracking issue.
Related Issues
None.
Questions
None.
Other
For each pull request, please update only one package.
Do not make unrelated or stylistic changes. Only replace inline NaN generation with the shared NaN constant and make required dependency updates.
As this is a Good First Issue, contributors are strongly encouraged to avoid AI for their first contributions and to follow existing project conventions closely.
Instructions
Description
This RFC proposes replacing inline NaN generation (for example, 0.0/0.0 or 0.0f/0.0f) in C source files, examples, benchmarks and README C usage snippets with the stdlib NaN constant from
@stdlib/constants/float64/nanor@stdlib/constants/float32/nan.In short, this RFC seeks to refactor code from this pattern:
to this pattern:
The migration is demonstrated in this PR commit fb7122c
In particular, notice three things:
STDLIB_CONSTANT_FLOAT64_NAN.@stdlib/constants/float64/nanto manifest configuration entries which compile that same C source file (typically build, benchmark, and examples, when applicable).By performing this refactoring, we facilitate:
Note:
Float32NaN occurrences as0.0f/0.0fwhich needs to be replaced bySTDLIB_CONSTANT_FLOAT32_NANfrom@stdlib/constants/float32/nan. Refer to this commit 767d45c for reference.Steps
Given the relatively widespread use of inline NaN generation, this RFC is an open call for contributors to do the following:
Study the example PR refactor: use
constants/float64/naninstats/strided/dnanmeanpn#11768 , refactor: useconstants/float32/naninstats/strided/snanmeanpn#11769 linked above, as it demonstrates the changes we are seeking.Ensure your local development environment is set up by following the contributing guide
Find one package containing inline NaN generation in C source files.
Update that package, and only that package, to use
STDLIB_CONSTANT_FLOAT64_NANfrom@stdlib/constants/float64/nan.Add the include statement for
stdlib/constants/float64/nan.h inupdated C sources.Update the package manifest dependencies for all task configurations that compile the updated source file.
Build the Node add-on and run the example, test and benchmark C files using the following commands
General command patterns:
For example, for
stats/base/dists/normal/pdf:Commit your changes.
Submit a PR updating that package only.
Use this PR title template:
refactor: use
constants/float64/nanin < package-name >In the PR body, use the phrase Resolves a part of , and not Resolves or Closes, because this is a tracking issue.
Related Issues
None.
Questions
None.
Other
Checklist