You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
factorisation in nmod_poly does not gracefully handle errors #73
In general I think that python-flint should avoid segfaults and aborts (except perhaps if it exposes a very low-level API).
There are some cases like this though where it is tricky because how can we know ahead of time that this will operation will or will not succeed?
In [3]: nmod_poly([1, 1], 10).factor()
Out[3]: (1, [(x+1, 1)])
If the modulus is prime it should always succeed. The Flint docs don't give any clue as to when this is expected to work or under what circumstances it might crash. At least python-flint should warn in its docs whether a particular function might abort because aborts are considered unfriendly in Python-land.
Oh for the sig_on() and sig_off() I think it just prints the error from C without the abort? So you have:
sig_on()
... some dangerous code
sig_off()
If the modulus is prime, then every element is invertible, a softer check is just ensuring that there's no non-trivial gcd before an inversion is called?
However cysignals would become another requirement for python-flint and I don't know if this is wanted?
Activity
oscarbenjamin commentedon Sep 7, 2023
In general I think that python-flint should avoid segfaults and aborts (except perhaps if it exposes a very low-level API).
There are some cases like this though where it is tricky because how can we know ahead of time that this will operation will or will not succeed?
If the modulus is prime it should always succeed. The Flint docs don't give any clue as to when this is expected to work or under what circumstances it might crash. At least python-flint should warn in its docs whether a particular function might abort because aborts are considered unfriendly in Python-land.
[-]nmod does not gracefully handle errors[/-][+]factorisation in nmod_poly does not gracefully handle errors[/+]GiacomoPope commentedon Sep 7, 2023
In SageMath a common trick is with the
sig_onandsig_offto check for issues, we could do something like that here?oscarbenjamin commentedon Sep 7, 2023
What check could be done besides just warning if the modulus is not prime?
GiacomoPope commentedon Sep 7, 2023
Oh for the
sig_on()andsig_off()I think it just prints the error from C without the abort? So you have:If the modulus is prime, then every element is invertible, a softer check is just ensuring that there's no non-trivial gcd before an inversion is called?
However
cysignalswould become another requirement forpython-flintand I don't know if this is wanted?oscarbenjamin commentedon Sep 7, 2023
Perhaps there could be an argument like
.factor(check=True)or something.