Implement more math commands (e.g. trig, ln)#7258
Conversation
8b2b09c to
b78b060
Compare
- [ ] Requires sign off from the team Reasoning: Most missing math commands are implemented with nushell#7258. The `meval` crate itself declares that it doesn't strive to stringent standards (https://docs.rs/meval/latest/meval/#related-projects). For example no particular special casing or transformations are performed to ensure numerical stability. It uses the same rust `std` library functions we use or have access to (and `f64`). While the command call syntax in nushell may be a bit more verbose, having a single source of truth and common commands is beneficial. Furthermore the `math` commands can themselves implement broadcasting over lists (or table columns). Closes nushell#7073 Removed dependencies: - `meval` - `nom 1.2.4` (duplicate)
- [ ] Requires sign off from the team Reasoning: Most missing math commands are implemented with nushell#7258. The `meval` crate itself declares that it doesn't strive to stringent standards (https://docs.rs/meval/latest/meval/#related-projects). For example no particular special casing or transformations are performed to ensure numerical stability. It uses the same rust `std` library functions we use or have access to (and `f64`). While the command call syntax in nushell may be a bit more verbose, having a single source of truth and common commands is beneficial. Furthermore the `math` commands can themselves implement broadcasting over lists (or table columns). Closes nushell#7073 Removed dependencies: - `meval` - `nom 1.2.4` (duplicate)
|
Lots of repetitive code here, as is the way when adding a bunch of commands. I skimmed through these, mainly looking for copy-n-paste errors and such, and none jumped out at me. I think we should move ahead with landing these and your other math pr too, and then take a look at combining all this stuff in a math plugin. I think it's the only way we'll be able to do any meaningful perf testing to determine if moving to a plugin is the right thing to do. |
|
Thanks for going through all the boilerplate @fdncred! Should I rebase the blocks of commands into their own commits so that removing them is easier if we decide to move them to a plugin? |
That sounds like a pain. I probably wouldn't. |
Currently implemented as commands Work towards nushell#7073 Add them to the example test harness together with `math round`
`math sin` `math cos` `math tan` Support degrees with the flag `--degrees`/`-d`
`math sinh` `math cosh` `math tanh`
- `math arcsin` - `math arccos` - `math arctan` Again include `--degrees` or `-d` for convenient output in degrees
- `math arcsinh` - `math arccosh` - `math arctanh`
- `math ln`
1a38cc5 to
2009a7b
Compare
I was a masochist in this case. |
`math sin` `math cos` `math tan` Support degrees with the flag `--degrees`/`-d`
`math sinh` `math cosh` `math tanh`
- `math arcsin` - `math arccos` - `math arctan` Again include `--degrees` or `-d` for convenient output in degrees
- `math arcsinh` - `math arccosh` - `math arctanh`
Reasoning: Most missing math commands are implemented with #7258. The `meval` crate itself declares that it doesn't strive to stringent standards (https://docs.rs/meval/latest/meval/#related-projects). For example no particular special casing or transformations are performed to ensure numerical stability. It uses the same rust `std` library functions we use or have access to (and `f64`). While the command call syntax in nushell may be a bit more verbose, having a single source of truth and common commands is beneficial. Furthermore the `math` commands can themselves implement broadcasting over lists (or table columns). Closes #7073 Removed dependencies: - `meval` - `nom 1.2.4` (duplicate) User-Facing Changes: Scripts using `math eval` will break. We remove a further `eval` like behavior to get results through runtime evaluation (albeit limited in scope) Tests: - Updated tests that internally used `math eval`. - Removed one test that primarily used `math eval` to obtain a result from `str join`
Description
Work towards #7073
math piandmath econstantsmath sinmath cosmath tanmath sinhmath coshmath tanhmath arcsinmath arccosmath arctanmath arcsinhmath arccoshmath arctanhmath lnTests + Formatting
math pi,math e, andmath round