Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register_as_coercion fails when no coercion map was already discovered #29517

Closed
xcaruso opened this issue Apr 16, 2020 · 13 comments
Closed

register_as_coercion fails when no coercion map was already discovered #29517

xcaruso opened this issue Apr 16, 2020 · 13 comments

Comments

@xcaruso
Copy link
Contributor

xcaruso commented Apr 16, 2020

Compare:

sage: A.<a> = ZZ[]
sage: B.<b> = ZZ[]
sage: phi = A.hom([b])
sage: phi.register_as_coercion()

with:

sage: A.<a> = ZZ[]
sage: B.<b> = ZZ[]
sage: B.has_coerce_map_from(A)
False
sage: phi = A.hom([b])
sage: phi.register_as_coercion()
Traceback (most recent call last):
...
AssertionError: coercion from Univariate Polynomial Ring in a over Integer Ring to Univariate Polynomial Ring in b over Integer Ring already registered or discovered

CC: @tscrim

Component: coercion

Author: Xavier Caruso

Branch/Commit: 1b1467b

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/29517

@xcaruso xcaruso added this to the sage-9.1 milestone Apr 16, 2020
@xcaruso
Copy link
Contributor Author

xcaruso commented Apr 16, 2020

Branch: u/caruso/register_coercion

@xcaruso
Copy link
Contributor Author

xcaruso commented Apr 16, 2020

Changed branch from u/caruso/register_coercion to none

@xcaruso
Copy link
Contributor Author

xcaruso commented Apr 16, 2020

Commit: 10ed24e

@xcaruso
Copy link
Contributor Author

xcaruso commented Apr 16, 2020

Branch: u/caruso/register_coercion

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

0e15a9ebetter test in register_coercion

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2020

Changed commit from 10ed24e to 0e15a9e

@tscrim
Copy link
Collaborator

tscrim commented Apr 16, 2020

comment:5

Doctest failure here:

File "src/sage/categories/morphism.pyx", line 269, in sage.categories.morphism.Morphism.register_as_coercion
Failed example:
    phi.register_as_coercion()
Expected:
    Traceback (most recent call last):
    ...
    AssertionError: coercion from Univariate Polynomial Ring in x over Integer Ring to Univariate Polynomial Ring in y over Integer Ring already registered or discovered
Got:
    <BLANKLINE>

I cannot remember if this behavior was intentional or not as we might not wanted to create a coercion after explicitly checking that there was not one as a safety check. However, even if that was the case, I think this is the more natural thing to permit since the user should really know what they are doing to add this.

So once the doctest is fixed, then you can set a positive review on my behalf.

@tscrim
Copy link
Collaborator

tscrim commented Apr 16, 2020

Reviewer: Travis Scrimshaw

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

1b1467bmodify a doctest

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 16, 2020

Changed commit from 0e15a9e to 1b1467b

@slel
Copy link
Member

slel commented Apr 16, 2020

comment:8

Missing author name.

@xcaruso
Copy link
Contributor Author

xcaruso commented Apr 16, 2020

Author: Xavier Caruso

@vbraun
Copy link
Member

vbraun commented Apr 18, 2020

Changed branch from u/caruso/register_coercion to 1b1467b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants