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

Cython 3.0 incompatible issue #425

Open
munechika-koyo opened this issue Jul 27, 2023 · 4 comments
Open

Cython 3.0 incompatible issue #425

munechika-koyo opened this issue Jul 27, 2023 · 4 comments

Comments

@munechika-koyo
Copy link
Contributor

Hello,

I found that runtime error about vector multiplication calculation like:

>>> from raysect.core.math import Vector3D
>>> Vector(1, 2, 3) * 2.0
Vector3D(2.0, 4.0, 6.0)

>>> 2.0 * Vector3D(1, 2, 3)
TypeError: unsupported operand type(s) for *: 'int' and 'raysect.core.math.vector.Vector3D'

This error cannot be seen if I compile raysect by cython < 3.0.0.
So, I suppose the issue is caused by cython 3.0 incompatibility.

@munechika-koyo
Copy link
Contributor Author

munechika-koyo commented Jul 27, 2023

when checking the docs (https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html),
I noticed that parameters of __mul__ method had been changed. (__mul__(x, y) -> __mul__(self, other))
This seems to cause the issue.

And we should implement __rmul__() reverse method.

@vsnever
Copy link
Contributor

vsnever commented Jul 27, 2023

Hi,
Yes, this applies to all binary arithmetic methods. As pointed out by @jacklovell in #373, there is a directive c_api_binop_methods=True that allows the old implementation to continue working. I was going to fix Raysect incompatibility with Cython 3.0, but haven't found the time yet. I will try to look in the near future, because this also affects Cherab.

@munechika-koyo
Copy link
Contributor Author

Thank you for your prompt reply.
I could not noticed that issue.
I am also trying to fix all binary arithmetic methods at least and going to push the PR, so please consider it if you are welcome.

@vsnever
Copy link
Contributor

vsnever commented Aug 1, 2023

I am also trying to fix all binary arithmetic methods at least and going to push the PR, so please consider it if you are welcome.

Thank you very much! The fix you proposed is fine with me. Let's wait for a response from @CnlPepper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants