-
Notifications
You must be signed in to change notification settings - Fork 27
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
0.4.4 tests fail in PyPy #74
Comments
I haven't tested with PyPy at all. What version of PyPy are you using for this? |
PyPy3.9 7.3.12 |
The tests all passed for me locally with PyPy3.9 7.3.11. |
I tried reproducing this in CI in #76 but the wheel build fails under PyPy. |
|
I'm a bit stuck here without being able to reproduce this. |
Do you have a local conda installation? If so, I can give instructions on how to reproduce, else I can try to set it up on CI. Note that the tests fail on all three OSes at conda-forge/python-flint-feedstock#31 |
I don't even want to try to fix this until we have CI that can reproduce the problem. If we don't test PyPy in CI then I would rather just say that it is not supported. |
I have just tested locally that I can build a wheel and install from it and all tests are passing. This is with pypy-3.9-7.3.11 which is the newest version available from pyenv. If the difference is pypy-3.9-7.3.12 rather than 7.3.11 then that might indicate a PyPy bug rather than a python-flint bug. The PRs to python-flint in between 0.4.2 and 0.4.4 are:
They are all just refactoring or unrelated changes. The bug reported is with 3-arg pow like: pow(1, flint.fmpz(2), 3) This is the code for fmpz.pow in 0.4.2: python-flint/src/flint/fmpz.pyx Lines 365 to 412 in b658fd3
This is the code in 0.4.4: python-flint/src/flint/types/fmpz.pyx Lines 358 to 405 in 24267a5
So unless I've missed something the code for fmpz.__pow__ is unchanged although there was a refactor that moved it to a different file.
The code still passes under CPython in any case. |
I checked with 7.3.11 in conda and the bug is still there |
It is a bug in 7.3.12. Disregard my previous comment. |
Is there an associated PyPy bug report for this? |
gh-93 fixes a bug to do with 3-arg pow but I am not sure if it is related to the bug here. |
I'm not sure how easy it is to support the 3-arg pow under PyPy. The mechanism that makes it work in CPython is quite obscure and only works from Cython (not pure Python): I can reproduce this locally now and also there is a new test failure under PyPy:
|
I haven't been able to set this up but does gmpy2 manage to do the 3-arg pow under PyPy? Under CPython it works just like python-flint does: >>> import gmpy2
>>> pow(2, gmpy2.mpz(3), 4)
mpz(0) This is what fails for python-flint under PyPy: >>>> import flint
>>>> pow(2, flint.fmpz(3), 4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: operands do not support pow() |
I think that we just have to add an exception for this in the test suite. Either PyPy and CPython need to find a compatible way of supporting the overload of 3-arg pow or it just is not possible to make this work under PyPy. Another possibility would be to just make it always a TypeError to do e.g. |
This needs investigating before releasing 0.5.0. |
The new test failure is basically this: In [14]: p = flint.fmpz_mod_poly_ctx(3)(0)
In [15]: p
Out[15]: 0
In [16]: p.leading_coefficient()
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[16], line 1
----> 1 p.leading_coefficient()
File ~/current/active/python-flint/src/flint/types/fmpz_mod_poly.pyx:893, in flint.types.fmpz_mod_poly.fmpz_mod_poly.leading_coefficient()
891 fmpz_mod(3, 163)
892 """
--> 893 return self[self.degree()]
894
895 def reverse(self, degree=None):
IndexError: %T index out of range Running the python code shown in the traceback gives: In [18]: p.degree()
Out[18]: -1
In [19]: p[-1]
Out[19]: fmpz_mod(0, 3)
In [17]: p[p.degree()]
Out[17]: fmpz_mod(0, 3) So This is either a Cython bug or a PyPy bug. Minimal reproducer without python-flint: # polymod.pyx
cdef class poly:
def __len__(self):
return 0
cpdef long degree(self):
return -1
def __getitem__(self, key):
if key < 0:
return 0
def leading_coefficient(self):
return self[self.degree()] Then under PyPy: >>>> import polymod
>>>> p = polymod.poly()
>>>> print(p.degree())
-1
>>>> print(p[-1])
0
>>>> print(p[p.degree()])
0
>>>> print(p.leading_coefficient())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "polymod.pyx", line 14, in polymod.poly.leading_coefficient
return self[self.degree()]
IndexError: %T index out of range |
This used to work in 0.4.2
The text was updated successfully, but these errors were encountered: