#16250: Monoids._test_one() incorrect for unhashable one elements
-------------------------------------+-------------------------------------
Reporter: saraedum | Owner:
Type: defect | Status: needs_review
Priority: trivial | Milestone: sage-6.3
Component: categories | Resolution:
Keywords: hash | Merged in:
Authors: Julian RĂ¼th | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/saraedum/ticket/16250 | c4f8c62f8da90c776a32a86dd768c490fc50836a
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nthiery):
Hi Julian,
Replying to [comment:9 saraedum]:
> Right. But what about any type for which equality depends on a
> p-adic number? (Say, a polynomial with p-adic coefficients.) If we
> don't want to have special classes for all these, then `__hash__` will
> have to raise a `TypeError` when computing the hash of its
> coefficients (see #11895).
Interesting example. Well, we are in the situation of class that
declares itself as hashable by providing a hash function, and then
later refutes this contract by throwing errors. I see this as a bug.
Alright, a minor enough bug that we may well not want to introduce
complicated infrastructure to fix it.
However changing test_one and test_zero for this is just hiding this
bug, and might hide other more important bugs in the future. I find
preferable to explicitly skip `_test_one()` in the doctests: this will
do what we mean: there is a known bug, and it's deemed minor enough to
ignore it.
Now, if we would want a real fix we could have polynomial rings check
whether there base ring elements can be hashed, and insert `__hash__ =
None`
in their custom element class. This could get tricky for a
Cython class though. But this states quite explicitly: I am hashable if my
base ring elements are.
Cheers,
Nicolas
--
Ticket URL: <http://trac.sagemath.org/ticket/16250#comment:11>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.