-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
added Vector2.from_polar and Vector3.from_spherical classmethods #2141
base: main
Are you sure you want to change the base?
added Vector2.from_polar and Vector3.from_spherical classmethods #2141
Conversation
I'm surprised upstream chose to make the same name method have two different signatures in two different scenarios. Is there a reason that
And maybe that would have simpler code? The implementation they chose works and is clever, but is a lot of complexity to add. |
I don't see why we can't have the same signature for both. I'll have to dedicate more time to rewriting it, so it might have to wait until this weekend. I have at least found a way to clean up the stub for the current implementation and I'll push a commit for that |
Just toggling this to re-run the CI as I think it is ready for review. |
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.
LGTM 👍
Good compatibility with upstream fixes.
Looks like this will need to merge with main to clear the CircleCI failure. |
It would be good to get this rebased and have the original author of this be added as a coauthor to the commit. |
# Conflicts: # buildconfig/stubs/pygame/math.pyi # docs/reST/ref/math.rst # src_c/doc/math_doc.h
Co-authored-by: joaquin30 <jpinoz@tuta.io>
…into Vector2.from_polar
…into Vector2.from_polar
Why not make these functions METH_FASTCALL? Instead of doing it in a separate PR doubling review time we should implement it here i think. |
Co-authored-by: Dan Lawrence <danintheshed@gmail.com>
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.
OK, still looks good to me after recent improvements 👍
I have little idea of how popular usage of these coordinate systems actually is among pygame-ce users but improving compatibility with upstream where it is doing generally useful things is a plus.
@@ -33,6 +33,7 @@ | |||
#define NO_PYGAME_C_API | |||
#include "doc/math_doc.h" | |||
|
|||
#include "base.c" |
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 don't think this is a good idea
@@ -2296,8 +2366,10 @@ MODINIT_DEFINE(base) | |||
c_api[26] = pg_TwoDoublesFromFastcallArgs; |
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.
but pg_TwoDoublesFromFastcallArgs is declared a static inline.
@overload # type: ignore | ||
@classmethod | ||
def from_polar(cls, value: Tuple[float, float], /) -> Vector2: ... |
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.
@overload # type: ignore | |
@classmethod | |
def from_polar(cls, value: Tuple[float, float], /) -> Vector2: ... | |
@overload | |
def from_polar(value: Tuple[float, float], /) -> Vector2: ... # type: ignore |
It looks like the hack for typing fails for the class call. A bit of experimentation gives a different fix, in mypy.
This should also be applied to from_spherical
.
P.S.: The new Point
and SequenceLike
types should be integrated into the PR if it is going to be merged.
Port of pygame/pygame#3744