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

Commit

Permalink
Trac 10513: use FreeModules(base_ring.category()) instead of FreeModu…
Browse files Browse the repository at this point in the history
…les(base_ring)
  • Loading branch information
pjbruin committed Jan 19, 2015
1 parent b1287e7 commit f0957f0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/sage/categories/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
sage: V = VectorSpace(RationalField(), 3)
sage: V.category()
Category of vector spaces over Rational Field
Category of vector spaces with basis over quotient fields
sage: G = SymmetricGroup(9)
sage: G.category()
Join of Category of finite permutation groups and Category of finite weyl groups
Expand Down
14 changes: 11 additions & 3 deletions src/sage/categories/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def __reduce__(self):
(<function Hom at ...>,
(Vector space of dimension 2 over Rational Field,
Vector space of dimension 3 over Rational Field,
Category of vector spaces over Rational Field,
Category of vector spaces with basis over quotient fields,
False))
TESTS::
Expand Down Expand Up @@ -1168,11 +1168,19 @@ def reversed(self):
EXAMPLES::
sage: H = Hom(ZZ^2, ZZ^3); H
Set of Morphisms from Ambient free module of rank 2 over the principal ideal domain Integer Ring to Ambient free module of rank 3 over the principal ideal domain Integer Ring in Category of modules with basis over Integer Ring
Set of Morphisms from Ambient free module of rank 2 over
the principal ideal domain Integer Ring to Ambient free
module of rank 3 over the principal ideal domain Integer
Ring in Category of modules with basis over (euclidean
domains and infinite enumerated sets)
sage: type(H)
<class 'sage.modules.free_module_homspace.FreeModuleHomspace_with_category'>
sage: H.reversed()
Set of Morphisms from Ambient free module of rank 3 over the principal ideal domain Integer Ring to Ambient free module of rank 2 over the principal ideal domain Integer Ring in Category of modules with basis over Integer Ring
Set of Morphisms from Ambient free module of rank 3 over
the principal ideal domain Integer Ring to Ambient free
module of rank 2 over the principal ideal domain Integer
Ring in Category of modules with basis over (euclidean
domains and infinite enumerated sets)
sage: type(H.reversed())
<class 'sage.modules.free_module_homspace.FreeModuleHomspace_with_category'>
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def category(x):
sage: V = VectorSpace(QQ,3)
sage: category(V)
Category of vector spaces over Rational Field
Category of vector spaces with basis over quotient fields
"""
try:
return x.category()
Expand Down
26 changes: 15 additions & 11 deletions src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,19 @@ def __init__(self, base_ring, rank, degree, sparse=False, category=None):
Ambient free module of rank 3 over the integral domain Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
sage: FreeModule(GF(7),3).category()
Join of Category of vector spaces over Finite Field of size 7 and Category of finite enumerated sets
Join of Category of vector spaces with basis over
(finite fields and subquotients of monoids and quotients
of semigroups) and Category of finite enumerated sets
sage: V = QQ^4; V.category()
Category of vector spaces over Rational Field
Category of vector spaces with basis over quotient fields
sage: V = GF(5)**20; V.category()
Join of Category of vector spaces over Finite Field of size 5 and Category of finite enumerated sets
Join of Category of vector spaces with basis over
(finite fields and subquotients of monoids and quotients
of semigroups) and Category of finite enumerated sets
sage: FreeModule(ZZ,3).category()
Category of modules with basis over Integer Ring
Category of modules with basis over (euclidean domains and infinite enumerated sets)
sage: (QQ^0).category()
Join of Category of vector spaces over Rational Field and Category of finite enumerated sets
Join of Category of vector spaces with basis over quotient fields and Category of finite enumerated sets
TESTS::
Expand Down Expand Up @@ -720,11 +724,8 @@ def __init__(self, base_ring, rank, degree, sparse=False, category=None):
raise ValueError("degree (=%s) must be nonnegative"%degree)

if category is None:
from sage.categories.all import Fields, FreeModules, VectorSpaces
if base_ring in Fields():
category = VectorSpaces(base_ring)
else:
category = FreeModules(base_ring)
from sage.categories.all import FreeModules
category = FreeModules(base_ring.category())
try:
if base_ring.is_finite() or rank == 0:
# Put the module in the category of finite enumerated
Expand Down Expand Up @@ -2988,7 +2989,10 @@ def _Hom_(self, Y, category):
sage: type(H)
<class 'sage.modules.free_module_homspace.FreeModuleHomspace_with_category'>
sage: H
Set of Morphisms from Vector space of dimension 2 over Rational Field to Ambient free module of rank 3 over the principal ideal domain Integer Ring in Category of vector spaces over Rational Field
Set of Morphisms from Vector space of dimension 2 over
Rational Field to Ambient free module of rank 3 over the
principal ideal domain Integer Ring in Category of vector
spaces with basis over quotient fields
"""
if Y.base_ring().is_field():
import vector_space_homspace
Expand Down
10 changes: 5 additions & 5 deletions src/sage/modules/free_module_homspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
sage: V2 = FreeModule(IntegerRing(),2)
sage: H = Hom(V3,V2)
sage: H
Set of Morphisms from Ambient free module of rank 3
over the principal ideal domain Integer Ring to
Ambient free module of rank 2
over the principal ideal domain Integer Ring
in Category of modules with basis over Integer Ring
Set of Morphisms from Ambient free module of rank 3 over the
principal ideal domain Integer Ring to Ambient free module
of rank 2 over the principal ideal domain Integer Ring in
Category of modules with basis over (euclidean domains and
infinite enumerated sets)
sage: B = H.basis()
sage: len(B)
6
Expand Down

0 comments on commit f0957f0

Please sign in to comment.