-
Notifications
You must be signed in to change notification settings - Fork 33
Add shift and truncate methods to nmod_poly #310
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
Conversation
It looks like there are FLINT functions for these methods for all poly types. Do you think you could add these for fmpz_poly, fmpq_poly, arb_poly and acb_poly as well? The usual way to test this would be to add tests in # (This covers fmpz_poly, fmpq_poly, nmod_poly, fmpz_mod_poly, fq_default_poly)
@all_polys
def test_all_polys_shift_truncate(args: _PolyTestCase[typ.epoly_p[Tc], Tc]) -> None:
P, _, _, _ = args
assert P([1, 2, 3]).left_shift(3) == P([0, 0, 0, 1, 2, 3])
assert P([1, 2, 3]).right_shift(1) == P([2, 3])
assert P([1, 2, 3]).truncate(4) == P([1, 2, 3])
assert P([1, 2, 3]).truncate(2) == P([1, 2])
def test_arb_acb_polys_shift() -> None:
for P in flint.acb_poly, flint.arb_poly:
assert P([1, 2, 3]).left_shift(3) == P([0, 0, 0, 1, 2, 3])
assert P([1, 2, 3]).right_shift(1) == P([2, 3])
assert P([1, 2, 3]).truncate(4) == P([1, 2, 3])
assert P([1, 2, 3]).truncate(2) == P([1, 2]) |
Sure, they are now added |
Thanks
Fair enough. Yes, they do need to be tested but I think as you say the awkwardness of the comparisons is probably why they are not. |
The linter cython-lint is complaining: $ cython-lint src/
/home/runner/work/python-flint/python-flint/src/flint/types/arb_poly.pyx:351:5: E303 too many blank lines (2)
/home/runner/work/python-flint/python-flint/src/flint/types/acb_poly.pyx:353:5: E303 too many blank lines (2) |
Could you add this to release notes in the README here: Lines 162 to 180 in 81784a9
|
96e4438
to
eb57101
Compare
It should be all good now. |
Looks good. Thanks! |
This PR adds a few methods to
nmod_poly
to make its interface closer tofmpz_mod_poly
. Currently there is no workaround to shift anmod_poly
with acceptable performance.