Skip to content

Add generic tests for polynomial types #90

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

Merged
merged 1 commit into from
Sep 29, 2023

Conversation

oscarbenjamin
Copy link
Collaborator

Adds a test_polys function that runs the same same generic tests over fmpz_poly, fmpq_poly and nmod_poly to share tests and ensure that the interfaces of the three types are consistent where appropriate. Some methods that were present on some types but not on others were added.

Comment on lines +1817 to +1831
def _all_polys():
return [
# (poly_type, scalar_type, is_field)
(flint.fmpz_poly, flint.fmpz, False),
(flint.fmpq_poly, flint.fmpq, True),
(lambda *a: flint.nmod_poly(*a, 17), lambda x: flint.nmod(x, 17), True),
]


def test_polys():
for P, S, is_field in _all_polys():

assert P([S(1)]) == P([1]) == P(P([1])) == P(1)

assert raises(lambda: P([None]), TypeError)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GiacomoPope if we write the tests more like this then we don't need to duplicate the test code for different types and it also means that we can test that the different types have consistent method names and signatures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree with this. I think once #87 is merged I will take the time to address the tests before working on fq types.

@oscarbenjamin oscarbenjamin merged commit 86f74c6 into flintlib:master Sep 29, 2023
@oscarbenjamin oscarbenjamin deleted the pr_generic_tests branch September 29, 2023 14:43
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

Successfully merging this pull request may close these issues.

2 participants