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

Commit

Permalink
Some review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Dec 27, 2013
1 parent 1411319 commit ea3ecfb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 14 deletions.
39 changes: 36 additions & 3 deletions src/sage/modular/abvar/homspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,36 @@ def __init__(self, domain, codomain, cat):

@lazy_attribute
def _matrix_space(self):
"""
Return the matrix space of ``self``.
.. WARNING::
During unpickling, the domain and codomain may be unable to
provide the necessary information. This is why this is a lazy
attribute. See :trac:`14793`.
EXAMPLES::
sage: Hom(J0(11), J0(22))._matrix_space
Full MatrixSpace of 2 by 4 dense matrices over Integer Ring
"""
return MatrixSpace(ZZ,2*self.domain().dimension(), 2*self.codomain().dimension())

# The following method is used in the coercion framework. Unfortunately, the default
# method would get the order of parent and data different from what is expected
# in MatrixMorphism.__init__
def _element_constructor_from_element_class(self, *args, **keywords):
"""
Used in the coercion framework. Unfortunately, the default method
would get the order of parent and data different from what is expected
in ``MatrixMorphism.__init__``.
EXAMPLES::
sage: H = Hom(J0(11), J0(22))
sage: phi = H(matrix(ZZ,2,4,[5..12])); phi # indirect doctest
Abelian variety morphism:
From: Abelian variety J0(11) of dimension 1
To: Abelian variety J0(22) of dimension 2
"""
return self.element_class(self, *args, **keywords)

def __call__(self, M):
Expand Down Expand Up @@ -753,6 +777,15 @@ def __init__(self, A, gens=None, category=None):
self._is_full_ring = gens is None

def __reduce__(self):
"""
Used in pickling.
EXAMPLES::
sage: E = J0(31).endomorphism_ring()
sage: loads(dumps(E)) == E
True
"""
return End, (self.domain(),self.domain().category())

def _repr_(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/fg_pid/fgp_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ class FGP_Homset_class(Homset):
Set of Morphisms from Finitely generated module V/W over Integer Ring with invariants (4, 12) to Finitely generated module V/W over Integer Ring with invariants (4, 12) in Category of modules over Integer Ring
sage: type(H)
<class 'sage.modules.fg_pid.fgp_morphism.FGP_Homset_class_with_category'>
"""
Element = FGP_Morphism
def __init__(self, X, Y, category=None):
Expand Down
20 changes: 10 additions & 10 deletions src/sage/modules/matrix_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,16 +1164,16 @@ def restrict(self, sub):
class MatrixMorphism(MatrixMorphism_abstract):
"""
A morphism defined by a matrix.
"""
def __init__(self, parent, A):
"""
INPUT:
INPUT:
- ``parent`` - a homspace
- ``A`` - matrix or a :class:`MatrixMorphism_abstract` instance
- ``parent`` - a homspace
- ``A`` - matrix or a :class:`MatrixMorphism_abstract` instance
"""
def __init__(self, parent, A):
"""
Initialize ``self``.
EXAMPLES::
Expand All @@ -1186,14 +1186,14 @@ def __init__(self, parent, A):
True
"""
if parent is None:
raise ValueError, "no parent given when creating this matrix morphism"
raise ValueError("no parent given when creating this matrix morphism")
if isinstance(A, MatrixMorphism_abstract):
A = A.matrix()
R = A.base_ring()
if A.nrows() != parent.domain().rank():
raise ArithmeticError, "number of rows of matrix (=%s) must equal rank of domain (=%s)"%(A.nrows(), parent.domain().rank())
raise ArithmeticError("number of rows of matrix (={}) must equal rank of domain (={})".format(A.nrows(), parent.domain().rank()))
if A.ncols() != parent.codomain().rank():
raise ArithmeticError, "number of columns of matrix (=%s) must equal rank of codomain (=%s)"%(A.ncols(), parent.codomain().rank())
raise ArithmeticError("number of columns of matrix (={}) must equal rank of codomain (={})".format(A.ncols(), parent.codomain().rank()))
self._matrix = A
MatrixMorphism_abstract.__init__(self, parent)

Expand Down
11 changes: 11 additions & 0 deletions src/sage/schemes/generic/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ class SchemeHomset_generic(HomsetWithBase):
Element = SchemeMorphism

def __reduce__(self):
"""
Used in pickling.
EXAMPLES::
sage: A2 = AffineSpace(QQ,2)
sage: A3 = AffineSpace(QQ,3)
sage: Hom = A3.Hom(A2)
sage: loads(Hom.dumps()) == Hom
True
"""
#return SchemeHomset.reduce_data(self)
return SchemeHomset, (self.domain(), self.codomain(), self.homset_category())

Expand Down

0 comments on commit ea3ecfb

Please sign in to comment.