Opened 5 months ago

Closed 5 months ago

#29517 closed defect (fixed)

register_as_coercion fails when no coercion map was already discovered

Reported by: caruso Owned by:
Priority: major Milestone: sage-9.1
Component: coercion Keywords:
Cc: tscrim Merged in:
Authors: Xavier Caruso Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 1b1467b (Commits) Commit: 1b1467b8d6ddeb999247eb00cf830917d926ed6f
Dependencies: Stopgaps:

Description

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

Change History (10)

comment:1 Changed 5 months ago by caruso

  • Branch set to u/caruso/register_coercion

comment:2 Changed 5 months ago by caruso

  • Branch u/caruso/register_coercion deleted
  • Status changed from new to needs_review

comment:3 Changed 5 months ago by caruso

  • Branch set to u/caruso/register_coercion
  • Commit set to 10ed24e3ed0b5440624d5f1a9b18d2f8f89d8126

comment:4 Changed 5 months ago by git

  • Commit changed from 10ed24e3ed0b5440624d5f1a9b18d2f8f89d8126 to 0e15a9e63d86091692fff04c925ae16a95b6362d

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

0e15a9ebetter test in register_coercion

comment:5 Changed 5 months ago by tscrim

  • Reviewers set to Travis Scrimshaw

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.

comment:6 Changed 5 months ago by git

  • Commit changed from 0e15a9e63d86091692fff04c925ae16a95b6362d to 1b1467b8d6ddeb999247eb00cf830917d926ed6f

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

1b1467bmodify a doctest

comment:7 Changed 5 months ago by caruso

  • Status changed from needs_review to positive_review

comment:8 Changed 5 months ago by slelievre

Missing author name.

comment:9 Changed 5 months ago by caruso

  • Authors set to Xavier Caruso

comment:10 Changed 5 months ago by vbraun

  • Branch changed from u/caruso/register_coercion to 1b1467b8d6ddeb999247eb00cf830917d926ed6f
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.