Skip to content

Commit ccb0934

Browse files
author
Release Manager
committed
gh-36550: remove deprecated name parameter in category ; capital for Coxeter This is removing a deprecated parameter "name" in the init of "Category". Also using the opportunity to add the capital to the name of Coxeter. ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. URL: #36550 Reported by: Frédéric Chapoton Reviewer(s): Matthias Köppe
2 parents 5c6004b + 092186f commit ccb0934

13 files changed

+106
-102
lines changed

src/sage/categories/bimodules.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,24 @@ class Bimodules(CategoryWithParameters):
3737

3838
def __init__(self, left_base, right_base, name=None):
3939
"""
40+
The ``name`` parameter is ignored.
41+
4042
EXAMPLES::
4143
4244
sage: C = Bimodules(QQ, ZZ)
4345
sage: TestSuite(C).run()
4446
"""
45-
if not ( left_base in Rings() or
46-
(isinstance(left_base, Category)
47-
and left_base.is_subcategory(Rings())) ):
47+
if not (left_base in Rings() or
48+
(isinstance(left_base, Category)
49+
and left_base.is_subcategory(Rings()))):
4850
raise ValueError("the left base must be a ring or a subcategory of Rings()")
49-
if not ( right_base in Rings() or
50-
(isinstance(right_base, Category)
51-
and right_base.is_subcategory(Rings())) ):
51+
if not (right_base in Rings() or
52+
(isinstance(right_base, Category)
53+
and right_base.is_subcategory(Rings()))):
5254
raise ValueError("the right base must be a ring or a subcategory of Rings()")
5355
self._left_base_ring = left_base
5456
self._right_base_ring = right_base
55-
Category.__init__(self, name)
57+
Category.__init__(self)
5658

5759
def _make_named_class_key(self, name):
5860
r"""

src/sage/categories/category.py

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118

119119
_join_cache = WeakValueDictionary()
120120

121+
121122
class Category(UniqueRepresentation, SageObject):
122123
r"""
123124
The base class for modeling mathematical categories, like for example:
@@ -448,7 +449,7 @@ class of ``C`` is a dynamic subclass ``Cs_with_category`` of
448449
cls = cls.__base__
449450
return super().__classcall__(cls, *args, **options)
450451

451-
def __init__(self, s=None):
452+
def __init__(self):
452453
"""
453454
Initialize this category.
454455
@@ -468,12 +469,10 @@ def __init__(self, s=None):
468469
469470
.. NOTE::
470471
471-
Specifying the name of this category by passing a string
472-
is deprecated. If the default name (built from the name of
473-
the class) is not adequate, please use
472+
If the default name of the category (built from the name of
473+
the class) is not adequate, please implement
474474
:meth:`_repr_object_names` to customize it.
475475
"""
476-
assert s is None
477476
self.__class__ = dynamic_class("{}_with_category".format(self.__class__.__name__),
478477
(self.__class__, self.subcategory_class, ),
479478
cache=False, reduction=None,
@@ -491,49 +490,38 @@ def _label(self):
491490
492491
"""
493492
t = str(self.__class__.__base__)
494-
t = t[t.rfind('.')+1:]
493+
t = t[t.rfind('.') + 1:]
495494
return t[:t.rfind("'")]
496495

497-
# TODO: move this code into the method _repr_object_names once passing a string is not accepted anymore
498-
@lazy_attribute
499-
def __repr_object_names(self):
496+
def _repr_object_names(self):
500497
"""
501-
Determine the name of the objects of this category
502-
from its type, if it has not been explicitly given
503-
at initialisation.
498+
Return the name of the objects of this category.
504499
505500
EXAMPLES::
506501
507-
sage: Rings()._Category__repr_object_names
508-
'rings'
509-
sage: PrincipalIdealDomains()._Category__repr_object_names
510-
'principal ideal domains'
502+
sage: FiniteGroups()._repr_object_names()
503+
'finite groups'
504+
sage: AlgebrasWithBasis(QQ)._repr_object_names()
505+
'algebras with basis over Rational Field'
506+
507+
TESTS::
511508
512509
sage: Rings()
513510
Category of rings
511+
sage: Rings()._repr_object_names()
512+
'rings'
513+
sage: PrincipalIdealDomains()._repr_object_names()
514+
'principal ideal domains'
514515
"""
515516
i = -1
516517
s = self._label
517-
while i < len(s)-1:
518+
while i < len(s) - 1:
518519
for i in range(len(s)):
519520
if s[i].isupper():
520-
s = s[:i] + " " + s[i].lower() + s[i+1:]
521+
s = s[:i] + " " + s[i].lower() + s[i + 1:]
521522
break
522523
return s.lstrip()
523524

524-
def _repr_object_names(self):
525-
"""
526-
Return the name of the objects of this category.
527-
528-
EXAMPLES::
529-
530-
sage: FiniteGroups()._repr_object_names()
531-
'finite groups'
532-
sage: AlgebrasWithBasis(QQ)._repr_object_names()
533-
'algebras with basis over Rational Field'
534-
"""
535-
return self.__repr_object_names
536-
537525
def _short_name(self):
538526
"""
539527
Return a CamelCase name for this category.
@@ -1256,7 +1244,7 @@ def structure(self):
12561244
recursively from the result of :meth:`additional_structure`
12571245
on the super categories of ``self``.
12581246
"""
1259-
result = { D for C in self.super_categories() for D in C.structure() }
1247+
result = {D for C in self.super_categories() for D in C.structure()}
12601248
if self.additional_structure() is not None:
12611249
result.add(self)
12621250
return frozenset(result)
@@ -1319,8 +1307,7 @@ def is_full_subcategory(self, other):
13191307
False
13201308
"""
13211309
return self.is_subcategory(other) and \
1322-
len(self.structure()) == \
1323-
len(other.structure())
1310+
len(self.structure()) == len(other.structure())
13241311

13251312
@cached_method
13261313
def full_super_categories(self):
@@ -1446,27 +1433,26 @@ def _test_category(self, **options):
14461433
Traceback (most recent call last):
14471434
...
14481435
AssertionError: Category of my objects is not a subcategory of Objects()
1449-
14501436
"""
1451-
from sage.categories.objects import Objects
1437+
from sage.categories.objects import Objects
14521438
from sage.categories.sets_cat import Sets
14531439
tester = self._tester(**options)
14541440
tester.assertTrue(isinstance(self.super_categories(), list),
1455-
"%s.super_categories() should return a list" % self)
1441+
"%s.super_categories() should return a list" % self)
14561442
tester.assertTrue(self.is_subcategory(Objects()),
1457-
"%s is not a subcategory of Objects()" % self)
1443+
"%s is not a subcategory of Objects()" % self)
14581444
tester.assertTrue(isinstance(self.parent_class, type))
14591445
tester.assertTrue(all(not isinstance(cat, JoinCategory) for cat in self._super_categories))
14601446
if not isinstance(self, JoinCategory):
1461-
tester.assertTrue(all(self._cmp_key > cat._cmp_key for cat in self._super_categories))
1462-
tester.assertTrue(self.is_subcategory( Category.join(self.super_categories()) )) # Not an obviously passing test with axioms
1447+
tester.assertTrue(all(self._cmp_key > cat._cmp_key for cat in self._super_categories))
1448+
tester.assertTrue(self.is_subcategory(Category.join(self.super_categories()))) # Not an obviously passing test with axioms
14631449

14641450
for category in self._all_super_categories_proper:
14651451
if self.is_full_subcategory(category):
14661452
tester.assertTrue(any(cat.is_subcategory(category)
1467-
for cat in self.full_super_categories()),
1468-
"Every full super category should be a super category"
1469-
"of some immediate full super category")
1453+
for cat in self.full_super_categories()),
1454+
"Every full super category should be a super category"
1455+
"of some immediate full super category")
14701456

14711457
if self.is_subcategory(Sets()):
14721458
tester.assertTrue(isinstance(self.parent_class, type))
@@ -1588,7 +1574,7 @@ def _make_named_class(self, name, method_provider, cache=False, picklable=True):
15881574
doccls = cls
15891575
else:
15901576
# Otherwise, check XXXMethods
1591-
assert inspect.isclass(method_provider_cls),\
1577+
assert inspect.isclass(method_provider_cls), \
15921578
"%s.%s should be a class" % (cls.__name__, method_provider)
15931579
mro = inspect.getmro(method_provider_cls)
15941580
if len(mro) > 2 or (len(mro) == 2 and mro[1] is not object):
@@ -1941,7 +1927,7 @@ def _meet_(self, other):
19411927
appropriate convention for A<B. Using subcategory calls
19421928
for A<B, but the current meet and join call for A>B.
19431929
"""
1944-
if self is other: # useful? fast pathway
1930+
if self is other: # useful? fast pathway
19451931
return self
19461932
elif self.is_subcategory(other):
19471933
return other
@@ -2050,14 +2036,13 @@ def _with_axiom_as_tuple(self, axiom):
20502036
return (axiom_attribute(self),)
20512037
warn(("Expecting {}.{} to be a subclass of CategoryWithAxiom to"
20522038
" implement a category with axiom; got {}; ignoring").format(
2053-
self.__class__.__base__.__name__, axiom, axiom_attribute))
2039+
self.__class__.__base__.__name__, axiom, axiom_attribute))
20542040

20552041
# self does not implement this axiom
2056-
result = (self, ) + \
2057-
tuple(cat
2058-
for category in self._super_categories
2059-
for cat in category._with_axiom_as_tuple(axiom))
2060-
hook = getattr(self, axiom+"_extra_super_categories", None)
2042+
result = (self, ) + tuple(cat
2043+
for category in self._super_categories
2044+
for cat in category._with_axiom_as_tuple(axiom))
2045+
hook = getattr(self, axiom + "_extra_super_categories", None)
20612046
if hook is not None:
20622047
assert inspect.ismethod(hook)
20632048
result += tuple(hook())
@@ -2593,6 +2578,7 @@ def is_Category(x):
25932578
"""
25942579
return isinstance(x, Category)
25952580

2581+
25962582
@cached_function
25972583
def category_sample():
25982584
r"""
@@ -2606,7 +2592,8 @@ def category_sample():
26062592
26072593
sage: from sage.categories.category import category_sample
26082594
sage: sorted(category_sample(), key=str) # needs sage.groups
2609-
[Category of G-sets for Symmetric group of order 8! as a permutation group,
2595+
[Category of Coxeter groups,
2596+
Category of G-sets for Symmetric group of order 8! as a permutation group,
26102597
Category of Hecke modules over Rational Field,
26112598
Category of Lie algebras over Rational Field,
26122599
Category of additive magmas, ...,
@@ -2900,6 +2887,7 @@ def _subcategory_hook_(self, C):
29002887
return False
29012888
return Unknown
29022889

2890+
29032891
#############################################################
29042892
# Join of several categories
29052893
#############################################################
@@ -2948,29 +2936,25 @@ def __init__(self, super_categories, **kwds):
29482936
29492937
INPUT:
29502938
2951-
- super_categories -- Categories to join. This category will
2939+
- ``super_categories`` -- Categories to join. This category will
29522940
consist of objects and morphisms that lie in all of these
29532941
categories.
29542942
2955-
- name -- An optional name for this category.
2943+
- ``name`` -- ignored
29562944
29572945
TESTS::
29582946
29592947
sage: from sage.categories.category import JoinCategory
29602948
sage: C = JoinCategory((Groups(), CommutativeAdditiveMonoids())); C
29612949
Join of Category of groups and Category of commutative additive monoids
29622950
sage: TestSuite(C).run()
2963-
29642951
"""
29652952
assert len(super_categories) >= 2
29662953
assert all(not isinstance(category, JoinCategory) for category in super_categories)
29672954
# Use __super_categories to not overwrite the lazy attribute Category._super_categories
29682955
# Maybe this would not be needed if the flattening/sorting is does consistently?
29692956
self.__super_categories = list(super_categories)
2970-
if 'name' in kwds:
2971-
Category.__init__(self, kwds['name'])
2972-
else:
2973-
Category.__init__(self)
2957+
Category.__init__(self)
29742958

29752959
def _make_named_class_key(self, name):
29762960
r"""

src/sage/categories/category_types.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def __init__(self, base, name=None):
170170
r"""
171171
Initialize ``self``.
172172
173+
The ``name`` parameter is ignored.
174+
173175
EXAMPLES::
174176
175177
sage: S = Spec(ZZ)
@@ -182,7 +184,7 @@ def __init__(self, base, name=None):
182184
sage: TestSuite(C).run()
183185
"""
184186
self.__base = base
185-
Category.__init__(self, name)
187+
Category.__init__(self)
186188

187189
def _test_category_over_bases(self, **options):
188190
"""
@@ -527,13 +529,15 @@ def __init__(self, ambient, name=None):
527529
"""
528530
Initialize ``self``.
529531
532+
The parameter ``name`` is ignored.
533+
530534
EXAMPLES::
531535
532536
sage: C = Ideals(IntegerRing())
533537
sage: TestSuite(C).run()
534538
"""
535539
self.__ambient = ambient
536-
Category.__init__(self, name)
540+
Category.__init__(self)
537541

538542
def ambient(self):
539543
"""

src/sage/categories/category_with_axiom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class from the base category class::
269269
covers the following examples::
270270
271271
sage: FiniteCoxeterGroups()
272-
Category of finite coxeter groups
272+
Category of finite Coxeter groups
273273
sage: FiniteCoxeterGroups() is CoxeterGroups().Finite()
274274
True
275275
sage: FiniteCoxeterGroups._base_category_class_and_axiom_origin

src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def Irreducible(self):
130130
sage: ComplexReflectionGroups().Irreducible()
131131
Category of irreducible complex reflection groups
132132
sage: CoxeterGroups().Irreducible()
133-
Category of irreducible coxeter groups
133+
Category of irreducible Coxeter groups
134134
135135
TESTS::
136136

src/sage/categories/coxeter_groups.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CoxeterGroups(Category_singleton):
4141
EXAMPLES::
4242
4343
sage: C = CoxeterGroups(); C
44-
Category of coxeter groups
44+
Category of Coxeter groups
4545
sage: C.super_categories()
4646
[Category of generalized coxeter groups]
4747
@@ -128,6 +128,17 @@ def additional_structure(self):
128128
Finite = LazyImport('sage.categories.finite_coxeter_groups', 'FiniteCoxeterGroups')
129129
Algebras = LazyImport('sage.categories.coxeter_group_algebras', 'CoxeterGroupAlgebras')
130130

131+
def _repr_object_names(self):
132+
"""
133+
Return the name of the objects of this category.
134+
135+
EXAMPLES::
136+
137+
sage: CoxeterGroups().Finite()
138+
Category of finite Coxeter groups
139+
"""
140+
return "Coxeter groups"
141+
131142
class ParentMethods:
132143
@abstract_method
133144
def coxeter_matrix(self):

src/sage/categories/finite_complex_reflection_groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def WellGenerated(self):
135135
desired output (well generated does not appear)::
136136
137137
sage: CoxeterGroups().Finite()
138-
Category of finite coxeter groups
138+
Category of finite Coxeter groups
139139
"""
140140
return self._with_axiom('WellGenerated')
141141

0 commit comments

Comments
 (0)