| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Creates a subclass of flint_mpoly_context to hold mod_mpoly specific methods and abstractions
|
Ah whoops, didn't realise enum.StrEnum was added in 3.11 |
Sorry, something went wrong.
|
Looks good. Thanks! |
Sorry, something went wrong.
| raise NotImplementedError("Complex roots are not supported for this polynomial") | ||
|
|
||
|
|
||
| class Ordering(enum.Enum): |
There was a problem hiding this comment.
Not an urgent issue but defining this here and not in the .pxd means that the type cannot be imported with cimport and used as the type declaration on cdef functions.
Sorry, something went wrong.
There was a problem hiding this comment.
I'm not sure how that would be achieved, though I might just be missing something.
A definition like
class Ordering(enum.Enum):
lex = "lex"
deglex = "deglex"
degrevlex = "degrevlex"cannot go in the pxd file. Similarly neither can an empty definition like
class Ordering(enum.Enum):
passThe class can't be declared as a cdef class because enum.Enum is not an extension type, which is also why the ordering_py_to_c and ordering_c_to_py functions are not members. This was why it was a cython enum previously.
Cython enums don't support string values, and it complains that a byte literal with more than one char isn't coercible to an integer, fair enough, C enums are only ints anyway. With a single byte the Cython compiler crashes.
We could go back to using a Cython cpdef enum with int values, but then using it within a type hint raises a very unhelpful error message when passed something that's not an int, "TypeError: an integer is required". The range of the enum isn't even enforced.
# in a .pyx
cpdef enum CheeseState:
hard = 1
soft = 2
runny = 3
def cheese(arg: CheeseState):
print(arg)>>> cheese(1)
1
>>> cheese(100000)
100000
>>> cheese("test")
...
TypeError: an integer is required
Sorry, something went wrong.
There was a problem hiding this comment.
We could ofc just do it ourselves with string values and functions to go between
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, I see it is a subclass of a Python class.
The whole enum business seems unnecessarily confusing in Python and Cython.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Relevant issue: #195
This PR:
The nmod_mpoly.any_as_scalar method is the only method to actually use self, this is required to get the modulus to allow conversion from arbitrary ints that are larger than ulong can hold
I've also removed the exceptions they raised, they never did anything anyway