#16250: Monoids._test_one() incorrect for unhashable one elements
------------------------------+------------------------
Reporter: saraedum | Owner:
Type: defect | Status: new
Priority: trivial | Milestone: sage-6.2
Component: categories | Resolution:
Keywords: hash | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
------------------------------+------------------------
Description changed by saraedum:
Old description:
> In `categories.Monoids._test_one()` the hash value of a monoid's one is
> tested.
> {{{
> tester.assertEqual(type(one.__hash__()), int)
> tester.assertEqual(one.__hash__(), one.__hash__())
> }}}
> For unhashable objects, such as a `p`-adic one this should not be tested.
> It currently works, because `__hash__()` is inherited and therefore
> defined. However, since `p`-adics overwrite `__richcmp__` (in
> `padic_generic_element.pyx`) they are not hashable, i.e., `hash(one)`
> raises a `TypeError`.
>
> The same problem exists for `AdditiveMonoids._test_zero()`.
New description:
In `categories.Monoids._test_one()` the hash value of a monoid's one is
tested.
{{{
tester.assertEqual(type(one.__hash__()), int)
tester.assertEqual(one.__hash__(), one.__hash__())
}}}
For unhashable objects, such as a `p`-adic one this should not be tested.
It currently works, because `__hash__()` is inherited and therefore
defined. However, since `p`-adics overwrite `__richcmp__` (in
`padic_generic_element.pyx`) they are not hashable, i.e., `hash(one)`
raises a `TypeError`.
The same problem exists for `CommutativeAdditiveMonoids._test_zero()`.
--
--
Ticket URL: <http://trac.sagemath.org/ticket/16250#comment:1>
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.