Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage.combinat.species: Update # needs #36643

Merged
merged 8 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions src/sage/combinat/species/characteristic_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,15 @@ def canonical_label(self):

def transport(self, perm):
"""
Returns the transport of this structure along the permutation
perm.
Return the transport of this structure along the permutation ``perm``.

EXAMPLES::

sage: F = species.CharacteristicSpecies(3)
sage: a = F.structures(["a", "b", "c"]).random_element(); a
{'a', 'b', 'c'}
sage: p = PermutationGroupElement((1,2))
sage: a.transport(p)
sage: p = PermutationGroupElement((1,2)) # needs sage.groups
sage: a.transport(p) # needs sage.groups
{'a', 'b', 'c'}
"""
return self
Expand All @@ -85,7 +84,7 @@ def automorphism_group(self):
sage: F = species.CharacteristicSpecies(3)
sage: a = F.structures(["a", "b", "c"]).random_element(); a
{'a', 'b', 'c'}
sage: a.automorphism_group()
sage: a.automorphism_group() # needs sage.groups
Symmetric group of order 3! as a permutation group
"""
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
Expand All @@ -111,7 +110,7 @@ def __init__(self, n, min=None, max=None, weight=None):
[0, 1, 0, 0]
sage: X.isotype_generating_series()[0:4]
[0, 1, 0, 0]
sage: X.cycle_index_series()[0:4]
sage: X.cycle_index_series()[0:4] # needs sage.modules
[0, p[1], 0, 0]

sage: F = species.CharacteristicSpecies(3)
Expand Down Expand Up @@ -204,8 +203,8 @@ def _cis_term(self, base_ring):
EXAMPLES::

sage: F = species.CharacteristicSpecies(2)
sage: g = F.cycle_index_series()
sage: g[0:5]
sage: g = F.cycle_index_series() # needs sage.modules
sage: g[0:5] # needs sage.modules
[0, 0, 1/2*p[1, 1] + 1/2*p[2], 0, 0]
"""
cis = SetSpecies(weight=self._weight).cycle_index_series(base_ring)
Expand All @@ -220,11 +219,11 @@ def _equation(self, var_mapping):
EXAMPLES::

sage: C = species.CharacteristicSpecies(2)
sage: Qz = QQ['z']
sage: R.<node0> = Qz[]
sage: var_mapping = {'z':Qz.gen(), 'node0':R.gen()}
sage: C._equation(var_mapping)
z^2
sage: Qz = QQ['z']
sage: R.<node0> = Qz[]
sage: var_mapping = {'z':Qz.gen(), 'node0':R.gen()}
sage: C._equation(var_mapping)
z^2
"""
return var_mapping['z']**(self._n)

Expand Down Expand Up @@ -252,7 +251,7 @@ def __init__(self, min=None, max=None, weight=None):
[1, 0, 0, 0]
sage: X.isotype_generating_series()[0:4]
[1, 0, 0, 0]
sage: X.cycle_index_series()[0:4]
sage: X.cycle_index_series()[0:4] # needs sage.modules
[p[], 0, 0, 0]

TESTS::
Expand Down Expand Up @@ -296,7 +295,7 @@ def __init__(self, min=None, max=None, weight=None):
[0, 1, 0, 0]
sage: X.isotype_generating_series()[0:4]
[0, 1, 0, 0]
sage: X.cycle_index_series()[0:4]
sage: X.cycle_index_series()[0:4] # needs sage.modules
[0, p[1], 0, 0]

TESTS::
Expand Down
35 changes: 18 additions & 17 deletions src/sage/combinat/species/composition_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def __init__(self, parent, labels, pi, f, gs):

sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: a = L.structures(['a','b','c']).random_element()
sage: a == loads(dumps(a))
sage: a = L.structures(['a','b','c']).random_element() # needs sage.libs.flint
sage: a == loads(dumps(a)) # needs sage.libs.flint
True
"""
self._partition = pi
Expand All @@ -41,7 +41,7 @@ def __repr__(self):

sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: L.structures(['a','b','c'])[0]
sage: L.structures(['a','b','c'])[0] # needs sage.libs.flint
F-structure: {{'a', 'b', 'c'}}; G-structures: (('a', 'b', 'c'),)
"""
f, gs = self._list
Expand All @@ -51,13 +51,13 @@ def transport(self, perm):
"""
EXAMPLES::

sage: p = PermutationGroupElement((2,3))
sage: p = PermutationGroupElement((2,3)) # needs sage.groups
sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: S = L.structures(['a','b','c']).list()
sage: a = S[2]; a
sage: S = L.structures(['a','b','c']).list() # needs sage.libs.flint
sage: a = S[2]; a # needs sage.libs.flint
F-structure: {{'a', 'c'}, {'b'}}; G-structures: (('a', 'c'), ('b'))
sage: a.transport(p)
sage: a.transport(p) # needs sage.groups sage.libs.flint
F-structure: {{'a', 'b'}, {'c'}}; G-structures: (('a', 'c'), ('b'))
"""
f, gs = self._list
Expand All @@ -83,10 +83,10 @@ def change_labels(self, labels):

sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: S = L.structures(['a','b','c']).list()
sage: a = S[2]; a
sage: S = L.structures(['a','b','c']).list() # needs sage.libs.flint
sage: a = S[2]; a # needs sage.libs.flint
F-structure: {{'a', 'c'}, {'b'}}; G-structures: (('a', 'c'), ('b'))
sage: a.change_labels([1,2,3])
sage: a.change_labels([1,2,3]) # needs sage.libs.flint
F-structure: {{1, 3}, {2}}; G-structures: [(1, 3), (2)]
"""
f, gs = self._list
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(self, F, G, min=None, max=None, weight=None):
sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: c = L.generating_series()[:3]
sage: L._check() #False due to isomorphism types not being implemented
sage: L._check() #False due to isomorphism types not being implemented # needs sage.libs.flint
False
sage: L == loads(dumps(L))
True
Expand All @@ -135,7 +135,7 @@ def _structures(self, structure_class, labels):

sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: L.structures(['a','b','c']).list()
sage: L.structures(['a','b','c']).list() # needs sage.libs.flint
[F-structure: {{'a', 'b', 'c'}}; G-structures: (('a', 'b', 'c'),),
F-structure: {{'a', 'b', 'c'}}; G-structures: (('a', 'c', 'b'),),
F-structure: {{'a', 'c'}, {'b'}}; G-structures: (('a', 'c'), ('b')),
Expand All @@ -145,6 +145,7 @@ def _structures(self, structure_class, labels):

TESTS::

sage: # needs sage.libs.flint
sage: a = _[2]
sage: f, gs = a._list
sage: f
Expand Down Expand Up @@ -180,7 +181,7 @@ def _isotypes(self, structure_class, labels):

sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: L.isotypes(['a','b','c']).list()
sage: L.isotypes(['a','b','c']).list() # needs sage.modules
Traceback (most recent call last):
...
NotImplementedError
Expand All @@ -204,7 +205,7 @@ def _itgs(self, series_ring, base_ring):

sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: L.isotype_generating_series()[:10]
sage: L.isotype_generating_series()[:10] # needs sage.modules
[1, 1, 2, 3, 5, 7, 11, 15, 22, 30]
"""
cis = self.cycle_index_series(base_ring)
Expand All @@ -216,7 +217,7 @@ def _cis(self, series_ring, base_ring):

sage: E = species.SetSpecies(); C = species.CycleSpecies()
sage: L = E(C)
sage: L.cycle_index_series()[:5]
sage: L.cycle_index_series()[:5] # needs sage.modules
[p[],
p[1],
p[1, 1] + p[2],
Expand All @@ -233,7 +234,7 @@ def _cis(self, series_ring, base_ring):
sage: E = species.SetSpecies()
sage: C = species.CycleSpecies(weight=t)
sage: S = E(C)
sage: S.isotype_generating_series()[:5] #indirect
sage: S.isotype_generating_series()[:5] #indirect # needs sage.modules
[1, t, t^2 + t, t^3 + t^2 + t, t^4 + t^3 + 2*t^2 + t]

We do the same thing with set partitions weighted by the number of
Expand All @@ -245,7 +246,7 @@ def _cis(self, series_ring, base_ring):
sage: E = species.SetSpecies()
sage: E_t = species.SetSpecies(min=1,weight=t)
sage: Par = E(E_t)
sage: Par.isotype_generating_series()[:5]
sage: Par.isotype_generating_series()[:5] # needs sage.modules
[1, t, t^2 + t, t^3 + t^2 + t, t^4 + t^3 + 2*t^2 + t]
"""
f_cis = self._F.cycle_index_series(base_ring)
Expand Down
14 changes: 7 additions & 7 deletions src/sage/combinat/species/cycle_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def permutation_group_element(self):
sage: F = species.CycleSpecies()
sage: a = F.structures(["a", "b", "c"])[0]; a
('a', 'b', 'c')
sage: a.permutation_group_element()
sage: a.permutation_group_element() # needs sage.groups
(1,2,3)
"""
from sage.groups.perm_gps.constructor import PermutationGroupElement
Expand All @@ -67,8 +67,8 @@ def transport(self, perm):
sage: F = species.CycleSpecies()
sage: a = F.structures(["a", "b", "c"])[0]; a
('a', 'b', 'c')
sage: p = PermutationGroupElement((1,2))
sage: a.transport(p)
sage: p = PermutationGroupElement((1,2)) # needs sage.groups
sage: a.transport(p) # needs sage.groups
('a', 'c', 'b')
"""
p = self.permutation_group_element()
Expand All @@ -88,12 +88,12 @@ def automorphism_group(self):
sage: P = species.CycleSpecies()
sage: a = P.structures([1, 2, 3, 4])[0]; a
(1, 2, 3, 4)
sage: a.automorphism_group()
sage: a.automorphism_group() # needs sage.groups
Permutation Group with generators [(1,2,3,4)]

::

sage: [a.transport(perm) for perm in a.automorphism_group()]
sage: [a.transport(perm) for perm in a.automorphism_group()] # needs sage.groups
[(1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4)]
"""
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
Expand Down Expand Up @@ -255,8 +255,8 @@ def _cis_callable(self, base_ring, n):
EXAMPLES::

sage: P = species.CycleSpecies()
sage: cis = P.cycle_index_series()
sage: cis[0:7]
sage: cis = P.cycle_index_series() # needs sage.modules
sage: cis[0:7] # needs sage.modules
[0,
p[1],
1/2*p[1, 1] + 1/2*p[2],
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/species/empty_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EmptySpecies(GenericCombinatorialSpecies, UniqueRepresentation):
[0, 0, 0, 0]
sage: X.isotype_generating_series()[0:4]
[0, 0, 0, 0]
sage: X.cycle_index_series()[0:4]
sage: X.cycle_index_series()[0:4] # needs sage.modules
[0, 0, 0, 0]

The empty species is the zero of the semi-ring of species.
Expand All @@ -55,7 +55,7 @@ class EmptySpecies(GenericCombinatorialSpecies, UniqueRepresentation):
sage: (X.isotype_generating_series()[0:4] ==
....: S.isotype_generating_series()[0:4])
True
sage: (X.cycle_index_series()[0:4] ==
sage: (X.cycle_index_series()[0:4] == # needs sage.modules
....: S.cycle_index_series()[0:4])
True

Expand All @@ -69,7 +69,7 @@ class EmptySpecies(GenericCombinatorialSpecies, UniqueRepresentation):
[0, 0, 0, 0]
sage: Y.isotype_generating_series()[0:4]
[0, 0, 0, 0]
sage: Y.cycle_index_series()[0:4]
sage: Y.cycle_index_series()[0:4] # needs sage.modules
[0, 0, 0, 0]

TESTS::
Expand Down
10 changes: 5 additions & 5 deletions src/sage/combinat/species/functorial_composition_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, F, G, min=None, max=None, weight=None):
sage: WP = species.SubsetSpecies()
sage: P2 = E2*E
sage: G = WP.functorial_composition(P2)
sage: G.isotype_generating_series()[0:5]
sage: G.isotype_generating_series()[0:5] # needs sage.modules
[1, 1, 2, 4, 11]

sage: G = species.SimpleGraphSpecies()
Expand All @@ -44,7 +44,7 @@ def __init__(self, F, G, min=None, max=None, weight=None):
<class 'sage.combinat.species.functorial_composition_species.FunctorialCompositionSpecies'>
sage: G == loads(dumps(G))
True
sage: G._check() #False due to isomorphism types not being implemented
sage: G._check() # False due to isomorphism types not being implemented # needs sage.modules
False
"""
self._F = F
Expand Down Expand Up @@ -81,7 +81,7 @@ def _isotypes(self, structure_class, s):
EXAMPLES::

sage: G = species.SimpleGraphSpecies()
sage: G.isotypes([1,2,3]).list()
sage: G.isotypes([1,2,3]).list() # needs sage.modules
Traceback (most recent call last):
...
NotImplementedError
Expand All @@ -103,7 +103,7 @@ def _itgs(self, series_ring, base_ring):
EXAMPLES::

sage: G = species.SimpleGraphSpecies()
sage: G.isotype_generating_series()[0:5]
sage: G.isotype_generating_series()[0:5] # needs sage.modules
[1, 1, 2, 4, 11]
"""
return self.cycle_index_series(base_ring).isotype_generating_series()
Expand All @@ -113,7 +113,7 @@ def _cis(self, series_ring, base_ring):
EXAMPLES::

sage: G = species.SimpleGraphSpecies()
sage: G.cycle_index_series()[0:5]
sage: G.cycle_index_series()[0:5] # needs sage.modules
[p[],
p[1],
p[1, 1] + p[2],
Expand Down
Loading
Loading