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
This happens because sympy's Integer.__eq__ will coerce the nmod to an integer. I have proposed to remove that behaviour in sympy/sympy#26795. With that change we would instead have:
This is at least consistent in the sense that unequal types might be expected to compare as unequal. What happens here is just that both types return NotImplemented and so the default for == is False.
I wonder though if it would be better for flint.nmod to check for __index__ (using operator.index) when checking for equality so that it could compare equal to other "integer-like" types like np.int64 etc. Then both of the above cases would return True and would behave the same for int or Integer or any other integer-like types.
It is not clear in general how positive characteristic rings should behave in Python because they don't fit anywhere in the numeric scheme. In some ways it would seem cleaner to say that nmod should never compare equal to an integer but maybe that just makes them awkward to use. That is how the behaviour currently works for other positive characteristic types though:
This comes from a SymPy issue: sympy/sympy#26791
Flint's nmod does not compare equal to SymPy's Integer type in the same way that ints do:
This happens because sympy's
Integer.__eq__
will coerce the nmod to an integer. I have proposed to remove that behaviour in sympy/sympy#26795. With that change we would instead have:This is at least consistent in the sense that unequal types might be expected to compare as unequal. What happens here is just that both types return
NotImplemented
and so the default for==
is False.I wonder though if it would be better for
flint.nmod
to check for__index__
(usingoperator.index
) when checking for equality so that it could compare equal to other "integer-like" types likenp.int64
etc. Then both of the above cases would return True and would behave the same forint
orInteger
or any other integer-like types.It is not clear in general how positive characteristic rings should behave in Python because they don't fit anywhere in the numeric scheme. In some ways it would seem cleaner to say that
nmod
should never compare equal to an integer but maybe that just makes them awkward to use. That is how the behaviour currently works for other positive characteristic types though:The text was updated successfully, but these errors were encountered: