Coerce maps

class sage.structure.coerce_maps.CCallableConvertMap_class
Bases: sage.categories.map.Map
class sage.structure.coerce_maps.CallableConvertMap
Bases: sage.categories.map.Map
class sage.structure.coerce_maps.DefaultConvertMap

Bases: sage.categories.map.Map

This morphism simply calls the codomain’s element_constructor method, passing in the codomain as the first argument.

class sage.structure.coerce_maps.DefaultConvertMap_unique

Bases: sage.structure.coerce_maps.DefaultConvertMap

This morphism simply defers action to the codomain’s element_constructor method, WITHOUT passing in the codomain as the first argument.

This is used for creating elements that don’t take a parent as the first argument to their __init__ method, for example, Integers, Rationals, Algebraic Reals... all have a unique parent. It is also used when the element_constructor is a bound method (whose self argument is assumed to be bound to the codomain).

class sage.structure.coerce_maps.ListMorphism
Bases: sage.categories.map.Map
class sage.structure.coerce_maps.NamedConvertMap

Bases: sage.categories.map.Map

This is used for creating a elements via the _xxx_ methods.

For example, many elements implement an _integer_ method to convert to ZZ, or a _rational_ method to convert to QQ.

method_name
class sage.structure.coerce_maps.TryMap
Bases: sage.categories.map.Map
sage.structure.coerce_maps.test_CCallableConvertMap(domain, name=None)

For testing CCallableConvertMap_class.

TESTS:

sage: from sage.structure.coerce_maps import test_CCallableConvertMap
sage: f = test_CCallableConvertMap(ZZ, 'test'); f
Conversion via c call 'test' map:
  From: Integer Ring
  To:   Integer Ring
sage: f(3)
24
sage: f(9)
720

Previous topic

Coerce actions

Next topic

Miscellaneous

This Page