Skip to content

Commit 9966288

Browse files
author
Release Manager
committed
Trac #29880: sage.categories.pushout.type_to_parent: Reimplement using py_scalar_parent
`type_to_parent` seems to be a less complete implementation of `py_scalar_parent`. The change on this ticket helps get rid some explicit imports from `sage.rings`. URL: https://trac.sagemath.org/29880 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): Travis Scrimshaw
2 parents e5c8e1c + 4b37cc6 commit 9966288

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/sage/categories/pushout.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -4352,12 +4352,8 @@ def type_to_parent(P):
43524352
...
43534353
TypeError: Not a scalar type.
43544354
"""
4355-
import sage.rings.all
4356-
if P is int:
4357-
return sage.rings.all.ZZ
4358-
elif P is float:
4359-
return sage.rings.all.RDF
4360-
elif P is complex:
4361-
return sage.rings.all.CDF
4362-
else:
4355+
from sage.structure.coerce import py_scalar_parent
4356+
parent = py_scalar_parent(P)
4357+
if parent is None:
43634358
raise TypeError("Not a scalar type.")
4359+
return parent

0 commit comments

Comments
 (0)