Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
better test in register_coercion
Browse files Browse the repository at this point in the history
  • Loading branch information
xcaruso committed Apr 16, 2020
1 parent 10ed24e commit 0e15a9e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/sage/structure/parent.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,18 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
Traceback (most recent call last):
...
AssertionError: coercion from Univariate Polynomial Ring in b over Integer Ring to Univariate Polynomial Ring in a over Integer Ring already registered or discovered
TESTS:
We check that :trac:`29517` has been fixed::
sage: A.<x> = ZZ[]
sage: B.<y> = ZZ[]
sage: B.has_coerce_map_from(A)
False
sage: B.register_coercion(A.hom([y]))
sage: x + y
2*y
"""
if isinstance(mor, map.Map):
if mor.codomain() is not self:
Expand All @@ -1565,7 +1577,8 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
raise TypeError("coercions must be parents or maps (got %s)" % type(mor))
D = mor.domain()

assert not (self._coercions_used and D in self._coerce_from_hash), "coercion from {} to {} already registered or discovered".format(D, self)
assert not (self._coercions_used and D in self._coerce_from_hash and
self._coerce_from_hash.get(D) is not None), "coercion from {} to {} already registered or discovered".format(D, self)
mor._is_coercion = True
self._coerce_from_list.append(mor)
self._registered_domains.append(D)
Expand Down

0 comments on commit 0e15a9e

Please sign in to comment.