Skip to content

feat: accept ranges in math trig and log commands - #19604

Merged
fdncred merged 3 commits into
nushell:mainfrom
joshbarros:feat/math-range-inputs
Nov 23, 2026
Merged

fdncred merged 3 commits into
nushell:mainfrom
joshbarros:feat/math-range-inputs

Conversation

@joshbarros

@joshbarros joshbarros commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds Type::Range to the input signatures of math sin/cos/tan, their inverse and hyperbolic variants, math ln, and math exp. The existing PipelineData::map path already handles ranges; only the signature blocked parsing.

Tests cover 0..10 for sin/exp and 1..10 for ln. cargo test -p nu-cmd-extra math:: passes; CodeRabbit reports 0 findings.

User-facing changes (Release notes)

math sin, math cos, math tan, their inverse and hyperbolic versions, math ln, and math exp now accept ranges. For example, 0..0.1..1 | math sin works without converting the range to a list first. Unbounded ranges are still rejected, matching math sqrt.

Additional notes

Fixes #19552.

@fdncred fdncred left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review overview

🟡 Changes recommended

Ranges work in all 14 commands, including the float-step range from #19552 and --degrees, and a value out of domain still errors at the range. One thing to fix before merge: an unbounded range like 0.. streams forever here, where math sqrt and the other math commands reject it. The other two are an example and a release note.

Findings: 0 High severity · 1 Medium severity · 2 Low severity

Open (3)

Notes from my clanker, checked on 43dc87f. Built the branch, ran cargo test -p nu-cmd-extra --lib -- math:: (17 passed), clippy with CI's flags, fmt and typos (all clean), and ran each case on the branch binary and on 0.117.1.

@joshbarros

Copy link
Copy Markdown
Contributor Author

Addressed all three review points: added the shared ensure_bounded_range check to all 14 commands (plus a regression test), added range examples to sin, ln, and exp, and added a release note to the PR body. cargo test -p nu-cmd-extra math:: passes (18 tests) and CodeRabbit is clean.

@fdncred fdncred left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review overview

🟡 Changes recommended

Two of the three threads are fixed and resolved. All 14 commands now reject 0.. with the same error as math sqrt, and the release note is in. Two things are left. The new exp example fails clippy, and I reopened the examples thread because math ln still has no range example. The 1..3 example I suggested there hits the same lint, since clippy reads 0.6931 as LN_2. 1..3..5 | math ln | math round --precision 4 gives [0.0, 1.0986, 1.6094] and passes clippy and test_examples.

Findings: 0 High severity · 1 Medium severity · 0 Low severity

Open (1)

Notes from my clanker, checked on 32c9095. Built the branch, ran cargo test -p nu-cmd-extra --lib -- math:: (18 passed), clippy with CI's flags (1 error), fmt and typos (clean), and ran 0.. | math <cmd> for all 14 commands on the branch binary and on 0.117.1.

@fdncred fdncred added notes:ready Indicates Ready for Release notes notes:additions Noted in "Additions" section labels Nov 20, 2026
@fdncred

fdncred commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

please follow the PR template. your headers are wrong. we use the release template information to make release notes

@pheenty

pheenty commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Implicitly converting bounded ranges to lists is still a better idea imo, because this way it also works for user-defined commands

@fdncred

fdncred commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Implicitly converting bounded ranges to lists is still a better idea imo, because this way it also works for user-defined commands

Agreed but it's not for this PR.

@joshbarros

Copy link
Copy Markdown
Contributor Author

Updated the PR body to the repository template, with the release note under User-facing changes (Release notes).

@fdncred
fdncred merged commit e43f7c9 into nushell:main Nov 23, 2026
14 checks passed
@fdncred

fdncred commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Thanks

@github-actions github-actions Bot added this to the v0.118.0 milestone Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:additions Noted in "Additions" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"command doesn't support range input"

3 participants