-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
feat(stdlib): Add asin
, acos
, atan
, isClose
to Number module
#1699
feat(stdlib): Add asin
, acos
, atan
, isClose
to Number module
#1699
Conversation
Note: refactor any tests that use |
afa10b4
to
251e4ed
Compare
asin
, acos
, isClose
to Number stdlibasin
, acos
, atan
, isClose
to Number stdlib
251e4ed
to
ea44db1
Compare
asin
, acos
, atan
, isClose
to Number stdlibasin
, acos
, atan
, isClose
to Number stdlib
b69cdcc
to
b0a21f2
Compare
stdlib/number.gr
Outdated
* @param relativeTolerance: The relative tolerance to use | ||
* @param absoluteTolerance: The absolute tolerance to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should probably be more descriptive because it's not clear what they do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to improve these and got them a bit better but i dont know if they are good enough yet,
https://docs.python.org/3/library/math.html I was looking at python's docs for the description.
I think this might also close: #303 if we are deciding to with oscar's approach anyway. |
This is blocked by #1776 |
12872af
to
323e276
Compare
323e276
to
791c663
Compare
This has been unblocked and the docs have been regenerated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the new descriptions! I think they make a lot of sense now. Just one tiny change and this looks good from me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stamp of approval from me! I'll let the stdlib expert @phated take a look and hit the merge button if he's happy with the docs.
@spotandjake I only see a copyright notice, but not a license. What's the license on the code you referred to? |
From my understanding as it's in the Public domain it doesn't need a license to be used. It seems to be unlicensed though. I'm happy to use a different implementation if we need to though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment about docs. I still need to double check the musl libc license
stdlib/number.gr
Outdated
* Computes the inverse tangent of the given angle | ||
* | ||
* @param angle: A number between -1 and 1, representing the angle's tangent value. | ||
* @returns The inverse tangent (angle in radians between `-pi/2` and `pi/2`) of x. If x is less than `-1` or greater than `1`, returns NaN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for all the returns in the file.
What is "x"? We usually say something like "of the given angle."
Also, the "if x is less" sentence needs to be something like "The result will be NaN if the given angle is not between -1 and 1." Or something similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made that change
7ba639c
to
30a5d04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More docs changes
stdlib/number.gr
Outdated
* @param b: The second value | ||
* @param relativeTolerance: The maximum tolerance to use relative to the larger absolute value `a` or `b` | ||
* @param absoluteTolerance: The absolute tolerance to use, regardless of the values of `a` or `b` | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* |
stdlib/number.gr
Outdated
p / q | ||
} | ||
/** | ||
* Computes the inverse sine of the given angle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Computes the inverse sine of the given angle | |
* Computes the inverse sine of the given angle. |
Period on top level descriptions, no period on arg descriptions
stdlib/number.gr
Outdated
/** | ||
* Computes the inverse sine of the given angle | ||
* | ||
* @param angle: A number between -1 and 1, representing the angle's sine value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param angle: A number between -1 and 1, representing the angle's sine value. | |
* @param angle: A number between -1 and 1, representing the angle's sine value |
stdlib/number.gr
Outdated
* Computes the inverse sine of the given angle | ||
* | ||
* @param angle: A number between -1 and 1, representing the angle's sine value. | ||
* @returns The inverse sine (angle in radians between `-pi/2` and `pi/2`) of the given `angle`. The result will be `NaN` if the given `angle` is less than `-1` or greater than `1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @returns The inverse sine (angle in radians between `-pi/2` and `pi/2`) of the given `angle`. The result will be `NaN` if the given `angle` is less than `-1` or greater than `1` | |
* @returns The inverse sine (angle in radians between `-pi/2` and `pi/2`) of the given `angle` or `NaN` if the given `angle` is not between `-1` and `1` |
How about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love It
stdlib/number.gr
Outdated
} | ||
|
||
/** | ||
* Computes the inverse cosine of the given angle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Computes the inverse cosine of the given angle | |
* Computes the inverse cosine of the given angle. |
stdlib/number.gr
Outdated
/** | ||
* Computes the inverse cosine of the given angle | ||
* | ||
* @param angle: A number between -1 and 1, representing the angle's cosine value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param angle: A number between -1 and 1, representing the angle's cosine value. | |
* @param angle: A number between -1 and 1, representing the angle's cosine value |
stdlib/number.gr
Outdated
* Computes the inverse cosine of the given angle | ||
* | ||
* @param angle: A number between -1 and 1, representing the angle's cosine value. | ||
* @returnsThe inverse cosine (angle in radians between `-pi/2` and `pi/2`) of the given `angle`. The result will be `NaN` if the given `angle` is less than `-1` or greater than `1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @returnsThe inverse cosine (angle in radians between `-pi/2` and `pi/2`) of the given `angle`. The result will be `NaN` if the given `angle` is less than `-1` or greater than `1` | |
* @returns The inverse cosine (angle in radians between `-pi/2` and `pi/2`) of the given `angle` or `NaN` if the given `angle` is not between `-1` and `1` |
stdlib/number.gr
Outdated
} | ||
|
||
/** | ||
* Computes the inverse tangent of the given angle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Computes the inverse tangent of the given angle | |
* Computes the inverse tangent of the given angle. |
stdlib/number.gr
Outdated
/** | ||
* Computes the inverse tangent of the given angle | ||
* | ||
* @param angle: A number between -1 and 1, representing the angle's tangent value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param angle: A number between -1 and 1, representing the angle's tangent value. | |
* @param angle: A number between -1 and 1, representing the angle's tangent value |
stdlib/number.gr
Outdated
* Computes the inverse tangent of the given angle | ||
* | ||
* @param angle: A number between -1 and 1, representing the angle's tangent value. | ||
* @returns The inverse tangent (angle in radians between `-pi/2` and `pi/2`) of the given `angle`. The result will be `NaN` if the given `angle` is less than `-1` or greater than `1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @returns The inverse tangent (angle in radians between `-pi/2` and `pi/2`) of the given `angle`. The result will be `NaN` if the given `angle` is less than `-1` or greater than `1` | |
* @returns The inverse tangent (angle in radians between `-pi/2` and `pi/2`) of the given `angle` or `NaN` if the given `angle` is not between `-1` and `1` |
Made those changes |
asin
, acos
, atan
, isClose
to Number stdlibasin
, acos
, atan
, isClose
to Number module
This pr adds
Number.asin
,Number.acos
andNumber.isClose
to the Number stdlib. I was just going to addasin
andacos
but given that the methods being used to calculateasin
andacos
are approximations I decided to also addisClose
to make the testing more concise.isClose is taken from https://peps.python.org/pep-0485/#proposed-implementation,
The license on it just says its in the public domain I think that means we can use it but I honestly dont know happy to find an alternative approach though if that isnt allowed.
The
asin
andacos
functions are from:https://git.musl-libc.org/cgit/musl/tree/src/math/asin.c
Just like
pow
.This is a draft because
isClose
is blocked on optional Arguments for a nice api, once that gets merged I will go back and refactor the function to not use Options.Blocked: #388
Work for: #1017
Note: if you guys are fine with merging in with a worse api based on options I am happy todo that too.