Skip to content
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

[Document the] secant function messing up sec unit #2095

Open
costerwi opened this issue Jan 28, 2021 · 4 comments
Open

[Document the] secant function messing up sec unit #2095

costerwi opened this issue Jan 28, 2021 · 4 comments
Labels
documentation Concerns about or enhancements to the mathjs documentation help wanted

Comments

@costerwi
Copy link
Contributor

costerwi commented Jan 28, 2021

I believe "sec" is a built-in alias for the time unit seconds. However, if I type "5 sec" into the https://mathnotepad.com (or the evaluate input on https://mathjs.org) the function sec seems to take precedence and throw a TypeError even though it is expecting a unit:

TypeError: Unexpected type of argument in function multiplyScalar (expected: number or Unit or string or boolean or BigNumber or Complex or Fraction, actual: function, index: 1)

Can we improve the parser to avoid this confusion? It seems the unit "sec" is currently unavailable.

@josdejong
Copy link
Owner

Thanks for bringing this up.

Example:

import { evaluate, format } from 'mathjs' 

console.log(format(evaluate('120 seconds to minutes'))) // '2 minutes'

console.log(format(evaluate('120 sec to minutes')))
// Uncaught TypeError: Unexpected type of argument in function multiplyScalar 
// (expected: number or Unit or string or boolean or BigNumber or Complex or Fraction, actual: function, index: 1)

@josdejong
Copy link
Owner

Anyone able to look into this bug?

@costerwi
Copy link
Contributor Author

The "min" (minimum) function interfering with the "min" (minutes) unit is another example.

@gwhitney gwhitney added documentation Concerns about or enhancements to the mathjs documentation and removed bug labels Oct 3, 2023
@gwhitney gwhitney changed the title Secant function messing up sec unit [Document the] secant function messing up sec unit Oct 3, 2023
@gwhitney
Copy link
Collaborator

gwhitney commented Oct 3, 2023

Since it seems as though the (side) discussion on this in #2771 was to just accept the fact that in the mathjs parser these units are overridden, changing this to be a documentation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Concerns about or enhancements to the mathjs documentation help wanted
Projects
None yet
Development

No branches or pull requests

3 participants