#19016: Better hash for Element
-------------------------------------+-------------------------------------
Reporter: ncohen | Owner:
Type: defect | Status: needs_work
Priority: critical | Milestone: sage-6.9
Component: misc | Resolution:
Keywords: | Merged in:
Authors: Nils Bruin, | Reviewers:
Vincent Delecroix | Work issues:
Report Upstream: N/A | Commit:
Branch: public/19016 | a0f830bf8dc0cbdeb75e45ee7bfee7b4fad33768
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nbruin):
Replying to [comment:85 vdelecroix]:
> Though, we have currently the following behavior that I do not quite
understand
> {{{
> sage: Ktemp.<atemp> = NumberField(x^2 + 2*3*7*11)
> sage: m = atemp.matrix()
> sage: m.set_immutable()
> sage: K.<a> = NumberField(atemp.minpoly(), embedding=m)
> sage: a*m
> [-462 0]
> [ 0 -462]
> sage: sage: a*m == m**2
> True
> }}}
That's just because the matrix that is passed to "embedding" for the field
that is reconstructed during action discovery is apparently newly
constructed (probably it's `embedding_morphism(K.0)`) and hence mutable
again (you can verify by adding `print self.is_mutable()` to
`_cache_key`). So while you can make the field properly by passing an
immutable (and hence hashable) matrix, stock sage still gives buggy
behaviour, because subsequent coercion discovery tries to construct the
field in an invalid way (and then eats the exception and abandons action
discovery).
This is an argument to make _cache_key more generally available:
apparently it's difficult to ensure that reconstructed construction
parameters are hashable. Of course, to get reliable behaviour we'd need to
make sure that `m._cache_key() == copy(m,is_immutable=True)`, which is not
true presently. (otherwise one can get lots of equal-but-not-identical
fields. But "embedding" is rather prone to that anyway)
--
Ticket URL: <http://trac.sagemath.org/ticket/19016#comment:86>
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.