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

Commit 9260d14

Browse files
committed
Merge branch 'u/tscrim/categories_lazy_series-34470' of https://github.com/sagemath/sagetrac-mirror into u/tscrim/derivatives_lazy_series-34413
2 parents 97df300 + ddc04a1 commit 9260d14

34 files changed

+3070
-4451
lines changed

src/doc/en/reference/combinat/module_list.rst

-3
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,8 @@ Comprehensive Module List
339339
sage/combinat/species/permutation_species
340340
sage/combinat/species/product_species
341341
sage/combinat/species/recursive_species
342-
sage/combinat/species/series
343-
sage/combinat/species/series_order
344342
sage/combinat/species/set_species
345343
sage/combinat/species/species
346-
sage/combinat/species/stream
347344
sage/combinat/species/structure
348345
sage/combinat/species/subset_species
349346
sage/combinat/species/sum_species

src/doc/en/reference/references/index.rst

+6
Original file line numberDiff line numberDiff line change
@@ -4198,6 +4198,7 @@ REFERENCES:
41984198
.. [MagmaHGM] *Hypergeometric motives* in Magma,
41994199
http://magma.maths.usyd.edu.au/~watkins/papers/HGM-chapter.pdf
42004200
4201+
42014202
.. [Mar1980] Jacques Martinet, Petits discriminants des corps de
42024203
nombres, Journ. Arithm. 1980, Cambridge Univ. Press,
42034204
1982, 151--193.
@@ -4384,6 +4385,11 @@ REFERENCES:
43844385
*Symmetric cyclotomic Hecke algebras* J. Algebra.
43854386
**205** (1998) pp. 275-293.
43864387
4388+
.. [MM2008] Manel Maia and Miguel Méndez.
4389+
On the arithmetic product of combinatorial species.
4390+
Discrete Mathematics (2008), Volume 308, Issue 23, pp. 5407-5427,
4391+
:arxiv:`math/0503436v2`.
4392+
43874393
.. [MM2015] \J. Matherne and \G. Muller, *Computing upper cluster algebras*,
43884394
Int. Math. Res. Not. IMRN, 2015, 3121-3149.
43894395

src/sage/categories/highest_weight_crystals.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,9 @@ def q_dimension(self, q=None, prec=None, use_product=False):
322322
1 + q + 2*q^2 + 2*q^3 + 4*q^4 + 5*q^5 + 7*q^6
323323
+ 9*q^7 + 13*q^8 + 16*q^9 + O(q^10)
324324
sage: qdim = C.q_dimension(); qdim
325-
1 + q + 2*q^2 + 2*q^3 + 4*q^4 + 5*q^5 + 7*q^6
326-
+ 9*q^7 + 13*q^8 + 16*q^9 + 22*q^10 + O(x^11)
327-
sage: qdim.compute_coefficients(15)
328-
sage: qdim
329-
1 + q + 2*q^2 + 2*q^3 + 4*q^4 + 5*q^5 + 7*q^6
330-
+ 9*q^7 + 13*q^8 + 16*q^9 + 22*q^10 + 27*q^11
331-
+ 36*q^12 + 44*q^13 + 57*q^14 + 70*q^15 + O(x^16)
332-
325+
1 + q + 2*q^2 + 2*q^3 + 4*q^4 + 5*q^5 + 7*q^6 + O(q^7)
326+
sage: qdim[:16]
327+
[1, 1, 2, 2, 4, 5, 7, 9, 13, 16, 22, 27, 36, 44, 57, 70]
333328
"""
334329
from sage.rings.integer_ring import ZZ
335330
WLR = self.weight_lattice_realization()
@@ -375,22 +370,21 @@ def iter_by_deg(gens):
375370
elif prec is None:
376371
# If we're here, we may not be a finite crystal.
377372
# In fact, we're probably infinite.
378-
from sage.combinat.species.series import LazyPowerSeriesRing
373+
from sage.rings.lazy_series_ring import LazyPowerSeriesRing
379374
if q is None:
380375
P = LazyPowerSeriesRing(ZZ, names='q')
381376
else:
382377
P = q.parent()
383378
if not isinstance(P, LazyPowerSeriesRing):
384379
raise TypeError("the parent of q must be a lazy power series ring")
385380
ret = P(iter_by_deg(mg))
386-
ret.compute_coefficients(10)
387381
return ret
388382

389383
from sage.rings.power_series_ring import PowerSeriesRing, PowerSeriesRing_generic
390384
if q is None:
391385
q = PowerSeriesRing(ZZ, 'q', default_prec=prec).gen(0)
392386
P = q.parent()
393-
ret = P.sum(c * q**deg for deg,c in enumerate(iter_by_deg(mg)))
387+
ret = P.sum(c * q**deg for deg, c in enumerate(iter_by_deg(mg)))
394388
if ret.degree() == max_deg and isinstance(P, PowerSeriesRing_generic):
395389
ret = P(ret, prec)
396390
return ret

src/sage/categories/sets_with_grading.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,21 @@ def generating_series(self):
212212
Non negative integers
213213
sage: N.generating_series()
214214
1/(-z + 1)
215+
216+
sage: Permutations().generating_series()
217+
1 + z + 2*z^2 + 6*z^3 + 24*z^4 + 120*z^5 + 720*z^6 + O(z^7)
218+
219+
.. TODO::
220+
221+
- Very likely, this should always return a lazy power series.
215222
"""
216-
from sage.combinat.species.series import LazyPowerSeriesRing
223+
from sage.sets.non_negative_integers import NonNegativeIntegers
224+
from sage.rings.lazy_series_ring import LazyPowerSeriesRing
217225
from sage.rings.integer_ring import ZZ
218-
R = LazyPowerSeriesRing(ZZ)
219-
R(self.graded_component(grade).cardinality() for grade in self.grading_set())
226+
if isinstance(self.grading_set(), NonNegativeIntegers):
227+
R = LazyPowerSeriesRing(ZZ, names="z")
228+
return R(lambda n: self.graded_component(n).cardinality())
229+
raise NotImplementedError
220230

221231
# TODO:
222232
# * asymptotic behavior: we need an object for asymptotic behavior and

src/sage/combinat/sf/sfa.py

+18
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,24 @@ def degree_zero_coefficient(self):
17221722
"""
17231723
return self.coefficient([])
17241724

1725+
def is_unit(self):
1726+
"""
1727+
Return whether this element is a unit in the ring.
1728+
1729+
EXAMPLES::
1730+
1731+
sage: m = SymmetricFunctions(ZZ).monomial()
1732+
sage: (2*m[2,1] + m[[]]).is_unit()
1733+
False
1734+
1735+
sage: m = SymmetricFunctions(QQ).monomial()
1736+
sage: (3/2*m([])).is_unit()
1737+
True
1738+
"""
1739+
m = self.monomial_coefficients(copy=False)
1740+
return len(m) <= 1 and self.coefficient([]).is_unit()
1741+
1742+
17251743
#SymmetricFunctionsBases.Filtered = FilteredSymmetricFunctionsBases
17261744
#SymmetricFunctionsBases.Graded = GradedSymmetricFunctionsBases
17271745

src/sage/combinat/species/all.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
- :ref:`section-examples-catalan`
1212
- :ref:`section-generic-species`
1313
14-
Lazy Power Series
15-
-----------------
16-
17-
- :ref:`sage.combinat.species.stream`
18-
- :ref:`sage.combinat.species.series_order`
19-
- :ref:`sage.combinat.species.series`
20-
- :ref:`sage.combinat.species.generating_series`
21-
2214
Basic Species
2315
-------------
2416
@@ -52,6 +44,8 @@
5244
from sage.misc.namespace_package import install_doc
5345
install_doc(__package__, __doc__)
5446

55-
from .series import LazyPowerSeriesRing
56-
from .recursive_species import CombinatorialSpecies
57-
from . import library as species
47+
from sage.misc.lazy_import import lazy_import
48+
lazy_import("sage.combinat.species.recursive_species", "CombinatorialSpecies")
49+
lazy_import("sage.combinat.species", "library", as_="species")
50+
del lazy_import
51+

src/sage/combinat/species/characteristic_species.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ def __init__(self, n, min=None, max=None, weight=None):
109109
[1]
110110
sage: X.structures([1,2]).list()
111111
[]
112-
sage: X.generating_series().coefficients(4)
112+
sage: X.generating_series()[0:4]
113113
[0, 1, 0, 0]
114-
sage: X.isotype_generating_series().coefficients(4)
114+
sage: X.isotype_generating_series()[0:4]
115115
[0, 1, 0, 0]
116-
sage: X.cycle_index_series().coefficients(4)
116+
sage: X.cycle_index_series()[0:4]
117117
[0, p[1], 0, 0]
118118
119119
sage: F = species.CharacteristicSpecies(3)
120-
sage: c = F.generating_series().coefficients(4)
120+
sage: c = F.generating_series()[0:4]
121121
sage: F._check()
122122
True
123123
sage: F == loads(dumps(F))
@@ -163,7 +163,7 @@ def _gs_term(self, base_ring):
163163
EXAMPLES::
164164
165165
sage: F = species.CharacteristicSpecies(2)
166-
sage: F.generating_series().coefficients(5)
166+
sage: F.generating_series()[0:5]
167167
[0, 0, 1/2, 0, 0]
168168
sage: F.generating_series().count(2)
169169
1
@@ -187,7 +187,7 @@ def _itgs_term(self, base_ring):
187187
EXAMPLES::
188188
189189
sage: F = species.CharacteristicSpecies(2)
190-
sage: F.isotype_generating_series().coefficients(5)
190+
sage: F.isotype_generating_series()[0:5]
191191
[0, 0, 1, 0, 0]
192192
193193
Here we test out weighting each structure by q.
@@ -196,7 +196,7 @@ def _itgs_term(self, base_ring):
196196
197197
sage: R.<q> = ZZ[]
198198
sage: Fq = species.CharacteristicSpecies(2, weight=q)
199-
sage: Fq.isotype_generating_series().coefficients(5)
199+
sage: Fq.isotype_generating_series()[0:5]
200200
[0, 0, q, 0, 0]
201201
"""
202202
return base_ring(self._weight)
@@ -207,7 +207,7 @@ def _cis_term(self, base_ring):
207207
208208
sage: F = species.CharacteristicSpecies(2)
209209
sage: g = F.cycle_index_series()
210-
sage: g.coefficients(5)
210+
sage: g[0:5]
211211
[0, 0, 1/2*p[1, 1] + 1/2*p[2], 0, 0]
212212
"""
213213
cis = SetSpecies(weight=self._weight).cycle_index_series(base_ring)
@@ -248,11 +248,11 @@ def __init__(self, min=None, max=None, weight=None):
248248
[{}]
249249
sage: X.structures([1,2]).list()
250250
[]
251-
sage: X.generating_series().coefficients(4)
251+
sage: X.generating_series()[0:4]
252252
[1, 0, 0, 0]
253-
sage: X.isotype_generating_series().coefficients(4)
253+
sage: X.isotype_generating_series()[0:4]
254254
[1, 0, 0, 0]
255-
sage: X.cycle_index_series().coefficients(4)
255+
sage: X.cycle_index_series()[0:4]
256256
[p[], 0, 0, 0]
257257
258258
TESTS::
@@ -290,11 +290,11 @@ def __init__(self, min=None, max=None, weight=None):
290290
[1]
291291
sage: X.structures([1,2]).list()
292292
[]
293-
sage: X.generating_series().coefficients(4)
293+
sage: X.generating_series()[0:4]
294294
[0, 1, 0, 0]
295-
sage: X.isotype_generating_series().coefficients(4)
295+
sage: X.isotype_generating_series()[0:4]
296296
[0, 1, 0, 0]
297-
sage: X.cycle_index_series().coefficients(4)
297+
sage: X.cycle_index_series()[0:4]
298298
[0, p[1], 0, 0]
299299
300300
TESTS::

src/sage/combinat/species/composition_species.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def transport(self, perm):
6262
f, gs = self._list
6363
pi = self._partition.transport(perm)
6464
f = f.change_labels(pi._list)
65-
g = [g.change_labels(part) for g, part in zip(gs, pi)] # BUG HERE ?
65+
_ = [g.change_labels(part) for g, part in zip(gs, pi)] # TODO: BUG HERE ?
6666
return self.__class__(self, self._labels, pi, f, gs)
6767

6868
def change_labels(self, labels):
@@ -105,7 +105,7 @@ def __init__(self, F, G, min=None, max=None, weight=None):
105105
sage: E = species.SetSpecies()
106106
sage: C = species.CycleSpecies()
107107
sage: S = E(C)
108-
sage: S.generating_series().coefficients(5)
108+
sage: S.generating_series()[:5]
109109
[1, 1, 1, 1, 1]
110110
sage: E(C) is S
111111
True
@@ -114,7 +114,7 @@ def __init__(self, F, G, min=None, max=None, weight=None):
114114
115115
sage: E = species.SetSpecies(); C = species.CycleSpecies()
116116
sage: L = E(C)
117-
sage: c = L.generating_series().coefficients(3)
117+
sage: c = L.generating_series()[:3]
118118
sage: L._check() #False due to isomorphism types not being implemented
119119
False
120120
sage: L == loads(dumps(L))
@@ -193,7 +193,7 @@ def _gs(self, series_ring, base_ring):
193193
194194
sage: E = species.SetSpecies(); C = species.CycleSpecies()
195195
sage: L = E(C)
196-
sage: L.generating_series().coefficients(5)
196+
sage: L.generating_series()[:5]
197197
[1, 1, 1, 1, 1]
198198
"""
199199
return self._F.generating_series(base_ring)(self._G.generating_series(base_ring))
@@ -204,7 +204,7 @@ def _itgs(self, series_ring, base_ring):
204204
205205
sage: E = species.SetSpecies(); C = species.CycleSpecies()
206206
sage: L = E(C)
207-
sage: L.isotype_generating_series().coefficients(10)
207+
sage: L.isotype_generating_series()[:10]
208208
[1, 1, 2, 3, 5, 7, 11, 15, 22, 30]
209209
"""
210210
cis = self.cycle_index_series(base_ring)
@@ -216,7 +216,7 @@ def _cis(self, series_ring, base_ring):
216216
217217
sage: E = species.SetSpecies(); C = species.CycleSpecies()
218218
sage: L = E(C)
219-
sage: L.cycle_index_series().coefficients(5)
219+
sage: L.cycle_index_series()[:5]
220220
[p[],
221221
p[1],
222222
p[1, 1] + p[2],
@@ -233,7 +233,7 @@ def _cis(self, series_ring, base_ring):
233233
sage: E = species.SetSpecies()
234234
sage: C = species.CycleSpecies(weight=t)
235235
sage: S = E(C)
236-
sage: S.isotype_generating_series().coefficients(5) #indirect
236+
sage: S.isotype_generating_series()[:5] #indirect
237237
[1, t, t^2 + t, t^3 + t^2 + t, t^4 + t^3 + 2*t^2 + t]
238238
239239
We do the same thing with set partitions weighted by the number of
@@ -245,17 +245,11 @@ def _cis(self, series_ring, base_ring):
245245
sage: E = species.SetSpecies()
246246
sage: E_t = species.SetSpecies(min=1,weight=t)
247247
sage: Par = E(E_t)
248-
sage: Par.isotype_generating_series().coefficients(5)
248+
sage: Par.isotype_generating_series()[:5]
249249
[1, t, t^2 + t, t^3 + t^2 + t, t^4 + t^3 + 2*t^2 + t]
250250
"""
251251
f_cis = self._F.cycle_index_series(base_ring)
252252
g_cis = self._G.cycle_index_series(base_ring)
253-
254-
#If G is a weighted species, then we can't use the default
255-
#algorithm for the composition of the cycle index series
256-
#since we must raise the weighting to the power.
257-
if self._G.is_weighted():
258-
return f_cis.weighted_composition(self._G)
259253
return f_cis(g_cis)
260254

261255
def weight_ring(self):

0 commit comments

Comments
 (0)