Skip to content

Commit

Permalink
adapt modularization tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse committed Aug 17, 2023
1 parent 8818d4a commit 3ca9915
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 108 deletions.
2 changes: 1 addition & 1 deletion src/sage/combinat/species/generating_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class CycleIndexSeriesRing(LazySymmetricFunctions):
We test to make sure that caching works::
sage: R is CycleIndexSeriesRing(QQ)
sage: R is CycleIndexSeriesRing(QQ) # optional - sage.modules
True
"""
Element = CycleIndexSeries
Expand Down
159 changes: 85 additions & 74 deletions src/sage/rings/lazy_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,30 +171,35 @@
....: yield n
....: n += 1
sage: L.<z> = LazyLaurentSeriesRing(GF(2)) # optional - sage.rings.finite_rings
sage: check(L, lambda n: n, valuation=-5) # optional - sage.rings.finite_rings
sage: check(L, gen(), valuation=-5) # optional - sage.rings.finite_rings
sage: L = LazyDirichletSeriesRing(QQbar, "s") # optional - sage.rings.number_field
sage: check(L, lambda n: n, valuation=2) # optional - sage.rings.number_field
sage: check(L, gen(), valuation=2) # optional - sage.rings.number_field
sage: L.<z> = LazyPowerSeriesRing(GF(2)) # optional - sage.rings.finite_rings
sage: check(L, lambda n: n, valuation=0) # optional - sage.rings.finite_rings
sage: check(L, gen(), valuation=0) # optional - sage.rings.finite_rings
sage: L.<x,y> = LazyPowerSeriesRing(GF(2)) # optional - sage.rings.finite_rings
sage: check(L, lambda n: (x + y)^n, valuation=None) # optional - sage.rings.finite_rings
sage: def gen(): # optional - sage.rings.finite_rings
sage: # needs sage.rings.finite_rings
sage: L.<z> = LazyLaurentSeriesRing(GF(2))
sage: check(L, lambda n: n, valuation=-5)
sage: check(L, gen(), valuation=-5)
sage: # needs sage.rings.number_field
sage: L = LazyDirichletSeriesRing(QQbar, "s")
sage: check(L, lambda n: n, valuation=2)
sage: check(L, gen(), valuation=2)
sage: # needs sage.rings.finite_rings
sage: L.<z> = LazyPowerSeriesRing(GF(2))
sage: check(L, lambda n: n, valuation=0)
sage: check(L, gen(), valuation=0)
sage: # needs sage.rings.finite_rings
sage: L.<x,y> = LazyPowerSeriesRing(GF(2))
sage: check(L, lambda n: (x + y)^n, valuation=None)
sage: def gen():
....: n = 0
....: while True:
....: yield (x+y)^n
....: n += 1
sage: check(L, gen(), valuation=None) # optional - sage.rings.finite_rings
sage: check(L, gen(), valuation=None)
sage: s = SymmetricFunctions(GF(2)).s() # optional - sage.combinat sage.rings.finite_rings
sage: L = LazySymmetricFunctions(s) # optional - sage.combinat sage.rings.finite_rings
sage: check(L, lambda n: sum(k*s(la) for k, la in enumerate(Partitions(n))), # optional - sage.combinat sage.rings.finite_rings
sage: # needs sage.combinat sage.rings.finite_rings
sage: s = SymmetricFunctions(GF(2)).s()
sage: L = LazySymmetricFunctions(s)
sage: check(L, lambda n: sum(k*s(la) for k, la in enumerate(Partitions(n))),
....: valuation=0)
Check that we can invert matrices::
Expand Down Expand Up @@ -535,12 +540,13 @@ def map_coefficients(self, f):
Similarly for lazy symmetric functions::
sage: p = SymmetricFunctions(QQ).p() # optional - sage.combinat
sage: L = LazySymmetricFunctions(p) # optional - sage.combinat
sage: f = 1/(1-2*L(p[1])); f # optional - sage.combinat
sage: # needs sage.combinat
sage: p = SymmetricFunctions(QQ).p()
sage: L = LazySymmetricFunctions(p)
sage: f = 1/(1-2*L(p[1])); f
p[] + 2*p[1] + (4*p[1,1]) + (8*p[1,1,1]) + (16*p[1,1,1,1])
+ (32*p[1,1,1,1,1]) + (64*p[1,1,1,1,1,1]) + O^7
sage: f.map_coefficients(lambda c: log(c, 2)) # optional - sage.combinat
sage: f.map_coefficients(lambda c: log(c, 2))
p[1] + (2*p[1,1]) + (3*p[1,1,1]) + (4*p[1,1,1,1])
+ (5*p[1,1,1,1,1]) + (6*p[1,1,1,1,1,1]) + O^7
Expand Down Expand Up @@ -994,56 +1000,57 @@ def __bool__(self):
TESTS::
sage: L.<z> = LazyLaurentSeriesRing(GF(2)) # optional - sage.rings.finite_rings
sage: bool(z - z) # optional - sage.rings.finite_rings
sage: # needs sage.rings.finite_rings
sage: L.<z> = LazyLaurentSeriesRing(GF(2))
sage: bool(z - z)
False
sage: f = 1/(1 - z) # optional - sage.rings.finite_rings
sage: bool(f) # optional - sage.rings.finite_rings
sage: f = 1/(1 - z)
sage: bool(f)
True
sage: M = L(lambda n: n, valuation=0); M # optional - sage.rings.finite_rings
sage: M = L(lambda n: n, valuation=0); M
z + z^3 + z^5 + O(z^7)
sage: M.is_zero() # optional - sage.rings.finite_rings
sage: M.is_zero()
False
sage: M = L(lambda n: 2*n if n < 10 else 1, valuation=0); M # optional - sage.rings.finite_rings
sage: M = L(lambda n: 2*n if n < 10 else 1, valuation=0); M
O(z^7)
sage: bool(M) # optional - sage.rings.finite_rings
sage: bool(M)
True
sage: M[15] # optional - sage.rings.finite_rings
sage: M[15]
1
sage: bool(M) # optional - sage.rings.finite_rings
sage: bool(M)
True
sage: L.<z> = LazyLaurentSeriesRing(GF(2), sparse=True) # optional - sage.rings.finite_rings
sage: M = L(lambda n: 2*n if n < 10 else 1, valuation=0); M # optional - sage.rings.finite_rings
sage: # needs sage.rings.finite_rings
sage: L.<z> = LazyLaurentSeriesRing(GF(2), sparse=True)
sage: M = L(lambda n: 2*n if n < 10 else 1, valuation=0); M
O(z^7)
sage: bool(M)
True
sage: M[15] # optional - sage.rings.finite_rings
sage: M[15]
1
sage: bool(M) # optional - sage.rings.finite_rings
sage: bool(M)
True
Uninitialized series::
sage: g = L.undefined(valuation=0) # optional - sage.rings.finite_rings
sage: bool(g) # optional - sage.rings.finite_rings
sage: # needs sage.rings.finite_rings
sage: g = L.undefined(valuation=0)
sage: bool(g)
True
sage: g.define(0) # optional - sage.rings.finite_rings
sage: bool(g) # optional - sage.rings.finite_rings
sage: g.define(0)
sage: bool(g)
False
sage: g = L.undefined(valuation=0) # optional - sage.rings.finite_rings
sage: bool(g) # optional - sage.rings.finite_rings
sage: g = L.undefined(valuation=0)
sage: bool(g)
True
sage: g.define(1 + z) # optional - sage.rings.finite_rings
sage: bool(g) # optional - sage.rings.finite_rings
sage: g.define(1 + z)
sage: bool(g)
True
sage: g = L.undefined(valuation=0) # optional - sage.rings.finite_rings
sage: bool(g) # optional - sage.rings.finite_rings
sage: g = L.undefined(valuation=0)
sage: bool(g)
True
sage: g.define(1 + z*g) # optional - sage.rings.finite_rings
sage: bool(g) # optional - sage.rings.finite_rings
sage: g.define(1 + z*g)
sage: bool(g)
True
"""
return bool(self._coeff_stream)
Expand Down Expand Up @@ -1156,14 +1163,15 @@ def define(self, s):
We can compute the Frobenius character of unlabeled trees::
sage: m = SymmetricFunctions(QQ).m() # optional - sage.combinat
sage: s = SymmetricFunctions(QQ).s() # optional - sage.combinat
sage: L = LazySymmetricFunctions(m) # optional - sage.combinat
sage: E = L(lambda n: s[n], valuation=0) # optional - sage.combinat
sage: X = L(s[1]) # optional - sage.combinat
sage: A = L.undefined() # optional - sage.combinat
sage: A.define(X*E(A, check=False)) # optional - sage.combinat
sage: A[:6] # optional - sage.combinat
sage: # needs sage.combinat
sage: m = SymmetricFunctions(QQ).m()
sage: s = SymmetricFunctions(QQ).s()
sage: L = LazySymmetricFunctions(m)
sage: E = L(lambda n: s[n], valuation=0)
sage: X = L(s[1])
sage: A = L.undefined()
sage: A.define(X*E(A, check=False))
sage: A[:6]
[m[1],
2*m[1, 1] + m[2],
9*m[1, 1, 1] + 5*m[2, 1] + 2*m[3],
Expand Down Expand Up @@ -1278,11 +1286,12 @@ def define(self, s):
sage: f
1 + 2*t + 12*t^3 + 32*t^4 + 368*t^5 + 2192*t^6 + O(t^7)
sage: s = SymmetricFunctions(QQ).s() # optional - sage.combinat
sage: L = LazySymmetricFunctions(s) # optional - sage.combinat
sage: f = L.undefined() # optional - sage.combinat
sage: f.define(1+(s[1]*f).revert()) # optional - sage.combinat
sage: f # optional - sage.combinat
sage: # needs sage.combinat
sage: s = SymmetricFunctions(QQ).s()
sage: L = LazySymmetricFunctions(s)
sage: f = L.undefined()
sage: f.define(1+(s[1]*f).revert())
sage: f
s[] + s[1] + (-s[1,1]-s[2])
+ (3*s[1,1,1]+6*s[2,1]+3*s[3])
+ (-13*s[1,1,1,1]-39*s[2,1,1]-26*s[2,2]-39*s[3,1]-13*s[4])
Expand Down Expand Up @@ -1413,12 +1422,13 @@ def _ascii_art_(self):
EXAMPLES::
sage: e = SymmetricFunctions(QQ).e() # optional - sage.combinat
sage: L.<z> = LazyLaurentSeriesRing(e) # optional - sage.combinat
sage: L.options.display_length = 3 # optional - sage.combinat
sage: ascii_art(1 / (1 - e[1]*z)) # optional - sage.combinat
sage: # needs sage.combinat
sage: e = SymmetricFunctions(QQ).e()
sage: L.<z> = LazyLaurentSeriesRing(e)
sage: L.options.display_length = 3
sage: ascii_art(1 / (1 - e[1]*z))
e[] + e[1]*z + e[1, 1]*z^2 + O(e[]*z^3)
sage: L.options._reset() # optional - sage.combinat
sage: L.options._reset()
"""
from sage.typeset.ascii_art import ascii_art, AsciiArt
if isinstance(self._coeff_stream, Stream_zero):
Expand All @@ -1433,12 +1443,13 @@ def _unicode_art_(self):
EXAMPLES::
sage: e = SymmetricFunctions(QQ).e() # optional - sage.combinat
sage: L.<z> = LazyLaurentSeriesRing(e) # optional - sage.combinat
sage: L.options.display_length = 3 # optional - sage.combinat
sage: unicode_art(1 / (1 - e[1]*z)) # optional - sage.combinat
sage: # needs sage.combinat
sage: e = SymmetricFunctions(QQ).e()
sage: L.<z> = LazyLaurentSeriesRing(e)
sage: L.options.display_length = 3
sage: unicode_art(1 / (1 - e[1]*z))
e[] + e[1]*z + e[1, 1]*z^2 + O(e[]*z^3)
sage: L.options._reset() # optional - sage.combinat
sage: L.options._reset()
"""
from sage.typeset.unicode_art import unicode_art, UnicodeArt
if isinstance(self._coeff_stream, Stream_zero):
Expand Down
Loading

0 comments on commit 3ca9915

Please sign in to comment.