diff --git a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx index d54644647d8..d519d37b618 100644 --- a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx +++ b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx @@ -120,11 +120,9 @@ cdef class LieAlgebraElement(IndexedFreeModuleElement): return s names = self.parent().variable_names() if base_map is None: - return codomain.sum(c * t._im_gens_(codomain, im_gens, names) - for t, c in self._monomial_coefficients.iteritems()) - else: - return codomain.sum(base_map(c) * t._im_gens_(codomain, im_gens, names) - for t, c in self._monomial_coefficients.iteritems()) + base_map = lambda x: x + return codomain.sum(base_map(c) * t._im_gens_(codomain, im_gens, names) + for t, c in self._monomial_coefficients.iteritems()) cpdef lift(self): """ diff --git a/src/sage/algebras/lie_algebras/morphism.py b/src/sage/algebras/lie_algebras/morphism.py index bea2d600b43..2ccf85263d7 100644 --- a/src/sage/algebras/lie_algebras/morphism.py +++ b/src/sage/algebras/lie_algebras/morphism.py @@ -23,6 +23,7 @@ from sage.structure.richcmp import richcmp from sage.matrix.constructor import matrix from itertools import combinations +from six import iteritems # TODO: Refactor out common functionality with RingHomomorphism_im_gens class LieAlgebraHomomorphism_im_gens(Morphism): @@ -607,8 +608,7 @@ def _call_(self, x): 1/3*A - 1/3*B + 2/3*C """ C = self.codomain() - if self._base_map is None: - return C.sum(c * self._im_gens[i] for i, c in x.to_vector().iteritems()) - else: - bh = self._base_map - return C.sum(bh(c) * self._im_gens[i] for i, c in x.to_vector().iteritems()) + bh = self._base_map + if bh is None: + bh = lambda t: t + return C.sum(bh(c) * self._im_gens[i] for i, c in iteritems(x.to_vector())) diff --git a/src/sage/quivers/representation.py b/src/sage/quivers/representation.py index 60a6b680ee3..6512e879fc5 100644 --- a/src/sage/quivers/representation.py +++ b/src/sage/quivers/representation.py @@ -2425,7 +2425,7 @@ def algebraic_dual(self, basis=False): from sage.quivers.homspace import QuiverHomSpace return QuiverHomSpace(self, self._semigroup.free_module(self.base_ring())).left_module(basis) - def Hom(self, codomain): + def Hom(self, codomain, category=None): """ Return the hom space from ``self`` to ``codomain``. @@ -2438,7 +2438,7 @@ def Hom(self, codomain): Dimension 2 QuiverHomSpace """ from sage.quivers.homspace import QuiverHomSpace - return QuiverHomSpace(self, codomain) + return QuiverHomSpace(self, codomain, category=category) def direct_sum(self, modules, return_maps=False): """ diff --git a/src/sage/rings/multi_power_series_ring_element.py b/src/sage/rings/multi_power_series_ring_element.py index cb8ef6e2804..111a0bf525d 100644 --- a/src/sage/rings/multi_power_series_ring_element.py +++ b/src/sage/rings/multi_power_series_ring_element.py @@ -552,10 +552,10 @@ def _subs_formal(self, *x, **kwds): y = 0 base_map = kwds.get('base_map') + if base_map is None: + base_map = lambda t: t for m, c in iteritems(self.dict()): - if base_map is not None: - c = base_map(c) - y += c*prod([x[i]**m[i] for i in range(n) if m[i] != 0]) + y += base_map(c)*prod([x[i]**m[i] for i in range(n) if m[i] != 0]) if self.prec() == infinity: return y else: diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx index 6843929a38c..50ca7fa616c 100644 --- a/src/sage/structure/parent.pyx +++ b/src/sage/structure/parent.pyx @@ -1346,6 +1346,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): codomain = im_gens.universe() if isinstance(im_gens, Sequence_generic): im_gens = list(im_gens) + # Not all homsets accept catgory/check/base_map as arguments kwds = {} if check is not None: kwds['check'] = check @@ -1358,7 +1359,8 @@ cdef class Parent(sage.structure.category_object.CategoryObject): # so we conservatively choose just SetsWithPartialMaps category = SetsWithPartialMaps() kwds['base_map'] = base_map - return self.Hom(codomain, category=category)(im_gens, **kwds) + Hom_kwds = {} if category is None else {'category': category} + return self.Hom(codomain, **Hom_kwds)(im_gens, **kwds) ################################################################################# # New Coercion support functionality