#14982: When a parent is equipped with an embedding, consider coercions that
don't
go through the embedding
-------------------------------------+-------------------------------------
Reporter: mmezzarobba | Owner:
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.4
Component: coercion | Resolution:
Keywords: embedding | Merged in:
Authors: Marc Mezzarobba, | Reviewers:
Vincent Delecroix | Work issues:
Report Upstream: N/A | Commit:
Branch: | ee261a37a06b53106c1640c7ef13b913f7cc2532
u/mmezzarobba/14982-coerce_embeddings| Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by vdelecroix):
Replying to [comment:48 mmezzarobba]:
> Replying to [comment:46 vdelecroix]:
> > I fixed the `q_binomial` issue (see the commit on top `public/14982`,
WARNING: it is merged with 6.7.beta2).
>
> Thanks, your fix is much better than what I did (even though the
particular issue would probably have been solved by the ticket about `I`).
Just one question: why are you doing
> ...
> instead of just
> ...
> (Are there cases where `R.zero()` would work but not `R(0)`? Or is it
faster that way when `R` is a `Parent`, despite the `try`/`catch` block?
And then, does speed matter?)
Here is an example:
{{{
sage: C = GF(5).cartesian_product(GF(5))
sage: C(0)
Traceback (most recent call last):
...
TypeError: 'sage.rings.integer.Integer' object is not iterable
sage: C(1)
Traceback (most recent call last):
...
TypeError: 'sage.rings.integer.Integer' object is not iterable
sage: C.zero()
(0, 0)
sage: C.one()
(1, 1)
}}}
But I guess that it should work because there always is a canonical
morphism `ZZ -> ring`. And here not
{{{
sage: C.has_coerce_map_from(ZZ)
False
}}}
So do not worry about this example. The version with `zero = R(0)` and
`one = R(1)` is much simpler. And anyway it is completely broken
{{{
sage: cyclotomic_value(4, C.one())
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for '-':
'The cartesian product of (Finite Field of size 5, Finite Field of size
5)'
and '<type 'int'>'
sage: q_binomial(4, 2, C.one())
Traceback (most recent call last):
..
RuntimeError: maximum recursion depth exceeded while calling a Python
object
}}}
Actually, this last example with infinite recursion is related to
coercions... so potentially there is something to dig further.
> But this example already didn't work before this ticket, did it?
Nope. Completely unrelated. Actually, it is related in the sense that the
was appearing in `prod(1 - q**i ...)`. And apparently it was the unique
reason of this huge `try/except` block that is removed by my commit.
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/14982#comment:52>
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.