Skip to content

docs: replace manual for loop in examples #6182

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

Merged
merged 5 commits into from
Mar 21, 2025

Conversation

anandkaranubc
Copy link
Contributor

Resolves None

Description

What is the purpose of this pull request?

This pull request:

  • replaces manual for loop in examples for math/base/special/a* packages

Related Issues

Does this pull request have any related issues?

This pull request:

  • resolves none

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

---
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: 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: na
  - 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
    status: passed
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Mar 19, 2025
@anandkaranubc
Copy link
Contributor Author

anandkaranubc commented Mar 19, 2025

Sorry, it ended up being a long PR, and that's just for packages starting with a. 🙃

Also, I noticed that the use of logEachMap truncates the input and output values to integers, resulting in outputs like:

asindf(0) = -36
asindf(0) = -40
asindf(0) = 23
...

I'm not sure if this behaviour is acceptable in cases where decimal values are expected. Thoughts...?

cc: @kgryte

@kgryte
Copy link
Member

kgryte commented Mar 19, 2025

@anandkaranubc You should read up on format specifiers: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format

In short, we support more than what console.log does. Meaning, you can specify precision, just like in printf in C.

@kgryte
Copy link
Member

kgryte commented Mar 19, 2025

%d in format corresponds to an integer. Hence, what you are seeing.

@stdlib-bot
Copy link
Contributor

stdlib-bot commented Mar 19, 2025

Coverage Report

Package Statements Branches Functions Lines
math/base/special/abs2 $\color{green}168/168$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}168/168$
$\color{green}+100.00\%$
math/base/special/abs2f $\color{green}175/175$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}175/175$
$\color{green}+100.00\%$
math/base/special/absf $\color{green}241/241$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}241/241$
$\color{green}+100.00\%$
math/base/special/acos $\color{green}217/217$
$\color{green}+100.00\%$
$\color{green}12/12$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}217/217$
$\color{green}+100.00\%$
math/base/special/acosd $\color{green}177/177$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}177/177$
$\color{green}+100.00\%$
math/base/special/acosdf $\color{green}185/185$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}185/185$
$\color{green}+100.00\%$
math/base/special/acosf $\color{red}291/293$
$\color{green}+99.32\%$
$\color{red}21/22$
$\color{green}+95.45\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{red}291/293$
$\color{green}+99.32\%$
math/base/special/acosh $\color{green}217/217$
$\color{green}+100.00\%$
$\color{green}14/14$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}217/217$
$\color{green}+100.00\%$
math/base/special/acot $\color{green}186/186$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}186/186$
$\color{green}+100.00\%$
math/base/special/acotd $\color{green}178/178$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}178/178$
$\color{green}+100.00\%$
math/base/special/acotdf $\color{green}187/187$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}187/187$
$\color{green}+100.00\%$
math/base/special/acotf $\color{green}193/193$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}193/193$
$\color{green}+100.00\%$
math/base/special/acoth $\color{green}175/175$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}175/175$
$\color{green}+100.00\%$
math/base/special/acovercos $\color{green}164/164$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}164/164$
$\color{green}+100.00\%$
math/base/special/acovercosf $\color{green}165/165$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}165/165$
$\color{green}+100.00\%$
math/base/special/acoversin $\color{green}168/168$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}168/168$
$\color{green}+100.00\%$
math/base/special/acoversinf $\color{green}169/169$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}169/169$
$\color{green}+100.00\%$
math/base/special/acsc $\color{green}178/178$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}178/178$
$\color{green}+100.00\%$
math/base/special/acscd $\color{green}188/188$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}188/188$
$\color{green}+100.00\%$
math/base/special/acscdf $\color{green}197/197$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}197/197$
$\color{green}+100.00\%$
math/base/special/acscf $\color{green}171/171$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}171/171$
$\color{green}+100.00\%$
math/base/special/acsch $\color{green}157/157$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}157/157$
$\color{green}+100.00\%$
math/base/special/ahavercos $\color{green}170/170$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}170/170$
$\color{green}+100.00\%$
math/base/special/ahavercosf $\color{green}171/171$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}171/171$
$\color{green}+100.00\%$
math/base/special/ahaversin $\color{green}169/169$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}169/169$
$\color{green}+100.00\%$
math/base/special/ahaversinf $\color{green}170/170$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}170/170$
$\color{green}+100.00\%$
math/base/special/asec $\color{green}160/160$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}160/160$
$\color{green}+100.00\%$
math/base/special/asecd $\color{green}188/188$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}188/188$
$\color{green}+100.00\%$
math/base/special/asecdf $\color{green}197/197$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}197/197$
$\color{green}+100.00\%$
math/base/special/asecf $\color{green}160/160$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}160/160$
$\color{green}+100.00\%$
math/base/special/asech $\color{green}160/160$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}160/160$
$\color{green}+100.00\%$
math/base/special/asin $\color{red}361/373$
$\color{green}+96.78\%$
$\color{red}27/32$
$\color{green}+84.38\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{red}361/373$
$\color{green}+96.78\%$
math/base/special/asind $\color{green}185/185$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}185/185$
$\color{green}+100.00\%$
math/base/special/asindf $\color{green}186/186$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}186/186$
$\color{green}+100.00\%$
math/base/special/asinf $\color{green}295/295$
$\color{green}+100.00\%$
$\color{green}25/25$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}295/295$
$\color{green}+100.00\%$
math/base/special/asinh $\color{green}235/235$
$\color{green}+100.00\%$
$\color{green}19/19$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}235/235$
$\color{green}+100.00\%$
math/base/special/atan $\color{green}346/346$
$\color{green}+100.00\%$
$\color{green}33/33$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}346/346$
$\color{green}+100.00\%$
math/base/special/atan2 $\color{green}290/290$
$\color{green}+100.00\%$
$\color{green}27/27$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}290/290$
$\color{green}+100.00\%$
math/base/special/atand $\color{green}188/188$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}188/188$
$\color{green}+100.00\%$
math/base/special/atandf $\color{green}193/193$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}193/193$
$\color{green}+100.00\%$
math/base/special/atanf $\color{green}284/284$
$\color{green}+100.00\%$
$\color{green}21/21$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}284/284$
$\color{green}+100.00\%$
math/base/special/atanh $\color{green}248/248$
$\color{green}+100.00\%$
$\color{green}24/24$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}248/248$
$\color{green}+100.00\%$
math/base/special/avercos $\color{green}164/164$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}164/164$
$\color{green}+100.00\%$
math/base/special/avercosf $\color{green}165/165$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}165/165$
$\color{green}+100.00\%$
math/base/special/aversin $\color{green}164/164$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}164/164$
$\color{green}+100.00\%$
math/base/special/aversinf $\color{green}165/165$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}165/165$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

@kgryte
Copy link
Member

kgryte commented Mar 19, 2025

I used %d in the abs commit, as the random values are discrete values. That won't be the case for other special functions.

@kgryte
Copy link
Member

kgryte commented Mar 19, 2025

We should update the docs for log-each and log-each-map to indicate that we support specifiers supported in string/format. Sorry for the confusion.

@anandkaranubc
Copy link
Contributor Author

Thanks for the feedback, @kgryte. Sorry, I should have been more careful about using the correct string format. Will update the PR accordingly.

@anandkaranubc
Copy link
Contributor Author

anandkaranubc commented Mar 19, 2025

We should update the docs for log-each and log-each-map to indicate that we support specifiers supported in string/format. Sorry for the confusion.

I'll see if I can contribute to that unless @headlessNode wants to take over.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Mar 19, 2025
@headlessNode
Copy link
Member

@anandkaranubc Feel free to make the changes you need

---
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: 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@anandkaranubc anandkaranubc requested a review from kgryte March 20, 2025 04:56
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Mar 20, 2025
@anandkaranubc anandkaranubc removed the Needs Changes Pull request which needs changes before being merged. label Mar 21, 2025
@anandkaranubc anandkaranubc marked this pull request as draft March 21, 2025 09:53
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Mar 21, 2025
---
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: 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: na
  - 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
    status: passed
  - 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: 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@anandkaranubc anandkaranubc marked this pull request as ready for review March 21, 2025 10:24
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Mar 21, 2025
@kgryte kgryte added the Documentation Improvements, additions, or changes to documentation. label Mar 21, 2025
Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kgryte kgryte removed the Needs Review A pull request which needs code review. label Mar 21, 2025
@kgryte kgryte merged commit 850472b into stdlib-js:develop Mar 21, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements, additions, or changes to documentation. Math Issue or pull request specific to math functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants