def _is_valid_homomorphism_(self, codomain, im_gens): ## NOTE: There are no ring homomorphisms from the ring of ## all formal power series to most rings, e.g, the p-adic ## field, since you can always (mathematically!) construct ## some power series that doesn't converge. ## Note that 0 is not a *ring* homomorphism. from power_series_ring import is_PowerSeriesRing if is_PowerSeriesRing(codomain) or is_LaurentSeriesRing(codomain): return im_gens[0].valuation() > 0 return False
def _is_valid_homomorphism_(self, codomain, im_gens): """ EXAMPLES:: sage: R.<x> = LaurentSeriesRing(GF(17)) sage: S.<y> = LaurentSeriesRing(GF(19)) sage: R.hom([y], S) # indirect doctest Traceback (most recent call last): ... TypeError: images do not define a valid homomorphism sage: f = R.hom(x+x^3,R) sage: f(x^2) x^2 + 2*x^4 + x^6 """ ## NOTE: There are no ring homomorphisms from the ring of ## all formal power series to most rings, e.g, the p-adic ## field, since you can always (mathematically!) construct ## some power series that doesn't converge. ## Note that 0 is not a *ring* homomorphism. from power_series_ring import is_PowerSeriesRing if is_PowerSeriesRing(codomain) or is_LaurentSeriesRing(codomain): return im_gens[0].valuation() > 0 and codomain.has_coerce_map_from(self.base_ring()) return False