Skip to content

Commit fcbdf00

Browse files
Release Managervbraun
Release Manager
authored andcommitted
Trac #15852: uncouple Sequence from categories
The `class Sequence` is difficult to place in the categories, as the discussion in this ticket shows. Rather, it has its place as programming utility, probably in `misc`. Thus, it needs not have a parent nor a category, nor mathematical operations like +, ... This ticket will deprecate/remove the corresponding methods. Previous description: The '''category `Sequence`''' is deprecated since 2009 (commit `619aa0fa`). If I understand it correctly, the '''class `Sequence`''' should instead have a parent from the category `Sets`. The ticket that will remove category `Sequence` depends on this. URL: http://trac.sagemath.org/15852 Reported by: rws Ticket author(s): Ralf Stephan Reviewer(s): Volker Braun
2 parents 1afa799 + 1f9c338 commit fcbdf00

File tree

12 files changed

+26
-195
lines changed

12 files changed

+26
-195
lines changed

src/doc/de/tutorial/tour_polynomial.rst

-3
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,6 @@ verwenden, nicht mehr funktionieren könnten)
309309
310310
::
311311

312-
sage: B.parent()
313-
Category of sequences in Multivariate Polynomial Ring in x, y over Rational
314-
Field
315312
sage: B.universe()
316313
Multivariate Polynomial Ring in x, y over Rational Field
317314
sage: B[1] = x

src/doc/en/tutorial/tour_polynomial.rst

-3
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,6 @@ break other routines that use the Gröbner basis).
303303
304304
::
305305

306-
sage: B.parent()
307-
Category of sequences in Multivariate Polynomial Ring in x, y over Rational
308-
Field
309306
sage: B.universe()
310307
Multivariate Polynomial Ring in x, y over Rational Field
311308
sage: B[1] = x

src/doc/fr/tutorial/tour_polynomial.rst

-3
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,6 @@ base de Gröbner).
311311
312312
::
313313

314-
sage: B.parent()
315-
Category of sequences in Multivariate Polynomial Ring in x, y over Rational
316-
Field
317314
sage: B.universe()
318315
Multivariate Polynomial Ring in x, y over Rational Field
319316
sage: B[1] = x

src/doc/pt/tutorial/tour_polynomial.rst

-3
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,6 @@ erros em outras rotinas que usam bases de Gröbner).
306306
307307
::
308308

309-
sage: B.parent()
310-
Category of sequences in Multivariate Polynomial Ring in x, y over Rational
311-
Field
312309
sage: B.universe()
313310
Multivariate Polynomial Ring in x, y over Rational Field
314311
sage: B[1] = x

src/doc/ru/tutorial/tour_polynomial.rst

-3
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ Sage использует Singular [Si]_ для вычислений НОД и
282282
283283
::
284284

285-
sage: B.parent()
286-
Category of sequences in Multivariate Polynomial Ring in x, y over Rational
287-
Field
288285
sage: B.universe()
289286
Multivariate Polynomial Ring in x, y over Rational Field
290287
sage: B[1] = x

src/sage/categories/all.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from category_types import(
44
Elements,
5-
Sequences,
65
SimplicialComplexes,
76
ChainComplexes,
87
)

src/sage/categories/category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,7 @@ def category_graph(categories = None):
26252625
Graphics object consisting of 20 graphics primitives
26262626
26272627
sage: sage.categories.category.category_graph().plot()
2628-
Graphics object consisting of 312 graphics primitives
2628+
Graphics object consisting of 310 graphics primitives
26292629
"""
26302630
from sage import graphs
26312631
if categories is None:

src/sage/categories/category_types.py

-86
Original file line numberDiff line numberDiff line change
@@ -110,92 +110,6 @@ def _latex_(self):
110110
return "\\mathbf{Elt}_{%s}"%latex(self.__object)
111111

112112

113-
#############################################################
114-
# Category of sequences of elements of objects
115-
#############################################################
116-
class Sequences(Category):
117-
"""
118-
The category of sequences of elements of a given object.
119-
120-
This category is deprecated.
121-
122-
EXAMPLES::
123-
124-
sage: v = Sequence([1,2,3]); v
125-
[1, 2, 3]
126-
sage: C = v.category(); C
127-
Category of sequences in Integer Ring
128-
sage: loads(C.dumps()) == C
129-
True
130-
sage: Sequences(ZZ) is C
131-
True
132-
133-
True
134-
sage: Sequences(ZZ).category()
135-
Category of objects
136-
"""
137-
def __init__(self, object):
138-
Category.__init__(self)
139-
self.__object = object
140-
141-
@classmethod
142-
def an_instance(cls):
143-
"""
144-
Returns an instance of this class
145-
146-
EXAMPLES::
147-
148-
sage: Elements(ZZ)
149-
Category of elements of Integer Ring
150-
"""
151-
from sage.rings.rational_field import QQ
152-
return cls(QQ)
153-
154-
def super_categories(self):
155-
"""
156-
EXAMPLES::
157-
158-
sage: Sequences(ZZ).super_categories()
159-
[Category of objects]
160-
"""
161-
return [Objects()] # Almost FiniteEnumeratedSets() except for possible repetitions
162-
163-
def _call_(self, x):
164-
"""
165-
EXAMPLES::
166-
167-
sage: v = Sequence([1,2,3]); v
168-
[1, 2, 3]
169-
sage: C = v.category(); C
170-
Category of sequences in Integer Ring
171-
sage: w = C([2/1, 3/1, GF(2)(5)]); w # indirect doctest
172-
[2, 3, 1]
173-
sage: w.category()
174-
Category of sequences in Integer Ring
175-
"""
176-
from sage.structure.sequence import Sequence
177-
return Sequence(x, self.__object)
178-
179-
def object(self):
180-
return self.__object
181-
182-
def __reduce__(self):
183-
return Sequences, (self.__object, )
184-
185-
def _repr_object_names(self):
186-
return "sequences in %s"%self.object()
187-
188-
def _latex_(self):
189-
r"""
190-
EXAMPLES::
191-
192-
sage: v = Sequence([1,2,3])
193-
sage: latex(v.category()) # indirect doctest
194-
\mathbf{Seq}_{\Bold{Z}}
195-
"""
196-
197-
return "\\mathbf{Seq}_{%s}"%latex(self.__object)
198-
199113
#############################################################
200114
# Category of objects over some base object
201115
#############################################################

src/sage/coding/code_constructions.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
from linear_code import LinearCodeFromVectorSpace, LinearCode
154154
from sage.modules.free_module import span
155155
from sage.schemes.projective.projective_space import ProjectiveSpace
156-
from sage.structure.sequence import Sequence
156+
from sage.structure.sequence import Sequence, Sequence_generic
157157
from sage.rings.arith import GCD,LCM,divisors,quadratic_residues
158158
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
159159
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
@@ -463,7 +463,10 @@ def permutation_action(g,v):
463463
if isinstance(v, list):
464464
v_type_list = True
465465
v = Sequence(v)
466-
V = v.parent()
466+
if isinstance(v, Sequence_generic):
467+
V = v.universe()
468+
else:
469+
V = v.parent()
467470
n = len(list(v))
468471
gv = []
469472
for i in range(n):

src/sage/databases/oeis.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -915,16 +915,16 @@ def natural_object(self):
915915
sage: fib = oeis('A000045') ; fib # optional -- internet
916916
A000045: Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
917917
918-
sage: x = fib.natural_object() ; x.parent() # optional -- internet
919-
Category of sequences in Non negative integer semiring
918+
sage: x = fib.natural_object() ; x.universe() # optional -- internet
919+
Non negative integer semiring
920920
921921
::
922922
923923
sage: sfib = oeis('A039834') ; sfib # optional -- internet
924924
A039834: a(n+2)=-a(n+1)+a(n) (signed Fibonacci numbers); or Fibonacci numbers (A000045) extended to negative indices.
925925
926-
sage: x = sfib.natural_object() ; x.parent() # optional -- internet
927-
Category of sequences in Integer Ring
926+
sage: x = sfib.natural_object() ; x.universe() # optional -- internet
927+
Integer Ring
928928
929929
TESTS::
930930
@@ -933,16 +933,16 @@ def natural_object(self):
933933
QQ as continued fractions
934934
935935
sage: s = oeis._imaginary_sequence('nonn')
936-
sage: s.natural_object().parent()
937-
Category of sequences in Non negative integer semiring
936+
sage: s.natural_object().universe()
937+
Non negative integer semiring
938938
939939
sage: s = oeis._imaginary_sequence()
940-
sage: s.natural_object().parent()
941-
Category of sequences in Integer Ring
940+
sage: s.natural_object().universe()
941+
Integer Ring
942942
"""
943943
if 'cofr' in self.keywords() and not 'frac' in self.keywords():
944944
return ContinuedFractionField()(self.first_terms())
945-
elif 'cons' in self.keywords():
945+
if 'cons' in self.keywords():
946946
offset = self.offsets()[0]
947947
terms = self.first_terms() + tuple([0] * abs(offset))
948948
return RealLazyField()('0' + ''.join(map(str, terms[:offset])) + '.' + ''.join(map(str, terms[offset:])))

src/sage/structure/parent.pyx

-11
Original file line numberDiff line numberDiff line change
@@ -2618,17 +2618,6 @@ cdef class Parent(category_object.CategoryObject):
26182618
else:
26192619
raise TypeError("_convert_map_from_ must return a map or callable (called on %s, got %s)" % (type(self), type(user_provided_mor)))
26202620

2621-
if not isinstance(S, type) and not isinstance(S, Parent):
2622-
# Sequences is not a Parent but a category!! As we would like to
2623-
# consider them as a parent we consider a workaround by using
2624-
# Set_PythonType from sage.structure.parent
2625-
from sage.categories.category_types import Sequences
2626-
from sage.structure.coerce_maps import ListMorphism
2627-
if isinstance(S, Sequences):
2628-
from sage.structure.sequence import Sequence_generic
2629-
SS = Set_PythonType(Sequence_generic)
2630-
return ListMorphism(SS, self.convert_map_from(list))
2631-
26322621
mor = self._generic_convert_map(S)
26332622
return mor
26342623

0 commit comments

Comments
 (0)