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

Commit

Permalink
Fix doctests and py3, incorporate small reviewer suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
roed314 committed Sep 12, 2019
1 parent 1f78dd4 commit 84704ba
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 3 additions & 5 deletions src/sage/algebras/lie_algebras/lie_algebra_element.pyx
Expand Up @@ -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):
"""
Expand Down
10 changes: 5 additions & 5 deletions src/sage/algebras/lie_algebras/morphism.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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()))
4 changes: 2 additions & 2 deletions src/sage/quivers/representation.py
Expand Up @@ -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``.
Expand All @@ -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):
"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/multi_power_series_ring_element.py
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/sage/structure/parent.pyx
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 84704ba

Please sign in to comment.