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

Issue with verify_isinstance() and generators #459

Closed
mhostetter opened this issue Jan 2, 2023 · 1 comment
Closed

Issue with verify_isinstance() and generators #459

mhostetter opened this issue Jan 2, 2023 · 1 comment
Labels
typing Related to type hints

Comments

@mhostetter
Copy link
Owner

While implementing #458, I discovered this:

In [25]: list(galois.irreducible_polys(2, 5, terms=10.0))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-25-72f6e34aff26> in <module>
----> 1 list(galois.irreducible_polys(2, 5, terms=10.0))

~\repos\galois\src\galois\_polys\_irreducible.py in irreducible_polys(order, degree, terms, reverse)
    172
    173         generator = galois.irreducible_polys(3, 4, reverse=True); generator
--> 174         next(generator)
    175         next(generator)
    176         next(generator)

~\repos\galois\src\galois\_helper.py in verify_isinstance(argument, types, optional)
     22         args = string[string.find("(") + 1 : -1].split(",")
     23         argument_name = args[0]
---> 24         raise TypeError(f"Argument {argument_name!r} must be an instance of {types}, not {type(argument)}.")
     25
     26

TypeError: Argument 'generator' must be an instance of <class 'int'>, not <class 'float'>.

The error should be:

TypeError: Argument `terms' must be an instance of <class 'int'>, not <class 'float'>.
@mhostetter mhostetter added the typing Related to type hints label Jan 2, 2023
@mhostetter
Copy link
Owner Author

This must have been a temporary bug on my local branch. Currently, #463 runs as follows:

In [1]: import galois

In [2]: list(galois.irreducible_polys(2, 5, terms=10.0))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 list(galois.irreducible_polys(2, 5, terms=10.0))

File /mnt/c/Users/matth/repos/galois/src/galois/_polys/_irreducible.py:187, in irreducible_polys(order, degree, terms, reverse)
    185 verify_isinstance(order, int)
    186 verify_isinstance(degree, int)
--> 187 verify_isinstance(terms, int, optional=True)
    188 verify_isinstance(reverse, bool)
    190 if not is_prime_power(order):

File /mnt/c/Users/matth/repos/galois/src/galois/_helper.py:24, in verify_isinstance(argument, types, optional)
     22 args = string[string.find("(") + 1 : -1].split(",")
     23 argument_name = args[0]
---> 24 raise TypeError(f"Argument {argument_name!r} must be an instance of {types}, not {type(argument)}.")

TypeError: Argument 'terms' must be an instance of <class 'int'>, not <class 'float'>.

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

No branches or pull requests

1 participant