#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 | 7b35c8a32ea67041665dddd8f1d98c7b8cfb6141
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by saraedum):
Replying to [comment:8 nthiery]:
> Replying to [comment:7 saraedum]:
> > I thought about this too. I agree that this would be better in theory.
The problem with this approach are things like matrices. They define a
hash which raises a `TypeError` if the matrix is mutable.
> - The methods one and zero should return immutable objects whenever
> possible, because more often than not the result is cached. If the
> result is a matrix this is no issue: it's enough to make it
> immutable. And then it becomes hashable. Part of the rationale of
> this test is precisely to check for this!
>
> - Having a method __hash__ that raises an error is bad advertising in
> the first place. In some cases it might be simpler to do it this way
> (e.g. for objects that can be immutable or not). But I would not
> want to particularly support this.
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 raise a
`TypeError` when computing the hash of its coefficients (see #11895).
--
Ticket URL: <http://trac.sagemath.org/ticket/16250#comment:9>
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.