-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
gh-150534: Add C23 half-turn trigonometric *pi functions
#150555
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
Open
jepler
wants to merge
21
commits into
python:main
Choose a base branch
from
jepler:c23-math-pifuns
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ad12476
Add *pi functions to math module
jepler 03808d6
Add news item and remove testing code
jepler e9ec2b6
tests: Add math_testcases for the new *pi functions
jepler bb57325
fix discussion of atan2pi
jepler 7650fa5
fix wrongly changed m_sinpi
jepler 86de1c0
regenerate autoconf files with `make regen-configure`
jepler be980bf
remove accidentally-committed code
jepler d3254cd
mathdata: Add +-inf, nan tests for new functions
jepler 6d8dd17
test_math: Let "mtestfile" test 2-arg functions
jepler 0c7fdfb
math_testcases: Add testcases for atan2pi
jepler aa93326
These are now tested in math_testcases.txt
jepler e0ede77
Add whatsnew entry for math module changes
jepler 694f479
Correct doc typos (atanpi2 -> atan2pi)
jepler ab68cdc
Correct comment about which standard this conforms to
jepler 359ac19
Add 'versionadded' notes to new functions
jepler 6cec4b8
Use float constants, not expressions, for simple values.
jepler d66a2c3
as x is finite, regular comparisons can be used here
jepler dcc5040
Merge remote-tracking branch 'origin/main' into c23-math-pifuns
jepler 1f98ce6
remove comment about glibc
jepler 12fcd24
Update comments based on review.
jepler 56da6fc
math_methods: Re-sort and conform to surrounding spacing
jepler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -83,13 +83,20 @@ noted otherwise, all return values are floats. | |||||||||
|
|
||||||||||
| **Trigonometric functions** | ||||||||||
| -------------------------------------------------------------------------------------------------- | ||||||||||
| :func:`acos(x) <acos>` Arc cosine of *x* | ||||||||||
| :func:`asin(x) <asin>` Arc sine of *x* | ||||||||||
| :func:`atan(x) <atan>` Arc tangent of *x* | ||||||||||
| :func:`atan2(y, x) <atan2>` ``atan(y / x)`` | ||||||||||
| :func:`cos(x) <cos>` Cosine of *x* | ||||||||||
| :func:`sin(x) <sin>` Sine of *x* | ||||||||||
| :func:`tan(x) <tan>` Tangent of *x* | ||||||||||
| :func:`acos(x) <acos>` Arc cosine of *x*, in radians | ||||||||||
| :func:`acospi(x) <acospi>` Arc cosine of *x*, in half-turns | ||||||||||
|
hugovk marked this conversation as resolved.
|
||||||||||
| :func:`asin(x) <asin>` Arc sine of *x*, in radians | ||||||||||
| :func:`asinpi(x) <asinpi>` Arc sine of *x*, in half-turns | ||||||||||
| :func:`atan(x) <atan>` Arc tangent of *x*, in radians | ||||||||||
| :func:`atanpi(x) <atanpi>` Arc tangent of *x*, in half-turns | ||||||||||
| :func:`atan2(y, x) <atan2>` ``atan(y / x)``, in radians | ||||||||||
| :func:`atan2pi(y, x) <atan2pi>` ``atan(y / x)``, in half-turns | ||||||||||
| :func:`cos(x) <cos>` Cosine of *x* radians | ||||||||||
| :func:`cospi(x) <cospi>` Cosine of *x⋅π* radians | ||||||||||
| :func:`sin(x) <sin>` Sine of *x* radians | ||||||||||
| :func:`sinpi(x) <sinpi>` Sine of *x⋅π* radians | ||||||||||
| :func:`tan(x) <tan>` Tangent of *x* radians | ||||||||||
| :func:`tanpi(x) <tanpi>` Tangent of *x⋅π* radians | ||||||||||
|
|
||||||||||
| **Hyperbolic functions** | ||||||||||
| -------------------------------------------------------------------------------------------------- | ||||||||||
|
|
@@ -597,18 +604,42 @@ Trigonometric functions | |||||||||
| ``pi``. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: acospi(x) | ||||||||||
|
|
||||||||||
| Return the arc cosine of *x*, in half-turns. The result is between ``0`` and | ||||||||||
| ``1``. | ||||||||||
|
|
||||||||||
|
skirpichev marked this conversation as resolved.
|
||||||||||
| .. versionadded:: next | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: asin(x) | ||||||||||
|
|
||||||||||
| Return the arc sine of *x*, in radians. The result is between ``-pi/2`` and | ||||||||||
| ``pi/2``. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: asinpi(x) | ||||||||||
|
|
||||||||||
| Return the arc sine of *x*, in half-turns. The result is between ``-0.5`` and | ||||||||||
| ``0.5``. | ||||||||||
|
|
||||||||||
| .. versionadded:: next | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: atan(x) | ||||||||||
|
|
||||||||||
| Return the arc tangent of *x*, in radians. The result is between ``-pi/2`` and | ||||||||||
| ``pi/2``. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: atanpi(x) | ||||||||||
|
|
||||||||||
| Return the arc tangent of *x*, in half-turns. The result is between ``-0.5`` and | ||||||||||
| ``0.5``. | ||||||||||
|
|
||||||||||
| .. versionadded:: next | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: atan2(y, x) | ||||||||||
|
|
||||||||||
| Return ``atan(y / x)``, in radians. The result is between ``-pi`` and ``pi``. | ||||||||||
|
|
@@ -619,21 +650,54 @@ Trigonometric functions | |||||||||
| -1)`` is ``-3*pi/4``. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: atan2pi(y, x) | ||||||||||
|
|
||||||||||
| Return ``atanpi(y / x)``, in half-turns. The result is between ``-1`` and ``1``. | ||||||||||
| The vector in the plane from the origin to point ``(x, y)`` makes this angle | ||||||||||
| with the positive X axis. The point of :func:`atan2pi` is that the signs of both | ||||||||||
| inputs are known to it, so it can compute the correct quadrant for the angle. | ||||||||||
| For example, ``atanpi(1)`` and ``atan2pi(1, 1)`` are both ``.25``, but | ||||||||||
| ``atan2pi(-1, -1)`` is ``-.75``. | ||||||||||
|
Comment on lines
+659
to
+660
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's be consistent with fractional values. |
||||||||||
|
|
||||||||||
| .. versionadded:: next | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: cos(x) | ||||||||||
|
|
||||||||||
| Return the cosine of *x* radians. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: cospi(x) | ||||||||||
|
|
||||||||||
| Return the cosine of *x* half-turns (*x⋅π* radians). | ||||||||||
|
|
||||||||||
| .. versionadded:: next | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: sin(x) | ||||||||||
|
|
||||||||||
| Return the sine of *x* radians. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: sinpi(x) | ||||||||||
|
|
||||||||||
| Return the sine of *x* half-turns (*x⋅π* radians). | ||||||||||
|
|
||||||||||
| .. versionadded:: next | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: tan(x) | ||||||||||
|
|
||||||||||
| Return the tangent of *x* radians. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| .. function:: tanpi(x) | ||||||||||
|
|
||||||||||
| Return the tangent of *x* half-turns (*x⋅π* radians). | ||||||||||
|
|
||||||||||
| .. versionadded:: next | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Hyperbolic functions | ||||||||||
| -------------------- | ||||||||||
|
|
||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.