genus

pocketpartition.core.genus.WithGenus(g)[source]

Yield all numerical semigroups of genus exactly g.

This is a thin wrapper around bfs_to_depth() rooted at the semigroup N (generated by {1}), which is the unique semigroup of genus 0 and the root of the semigroup tree.

Parameters:

g (int) – The target genus. Must be non-negative; negative values produce no output.

Yields:

NumericalSemigroup – Each numerical semigroup whose genus equals g.

Examples

>>> from pocketpartition import WithGenus
>>> semigroups = list(WithGenus(3))
>>> len(semigroups)
4
>>> all(S.genus == 3 for S in semigroups)
True
pocketpartition.core.genus.WithMaxGenus(g)[source]

Yield all numerical semigroups of genus at most g.

This is a thin wrapper around bfs_up_to_depth() rooted at the semigroup N (generated by {1}), which is the unique semigroup of genus 0 and the root of the semigroup tree.

Parameters:

g (int) – The maximum genus to include. Must be non-negative; negative values produce no output.

Yields:

NumericalSemigroup – Each numerical semigroup whose genus is in {0, 1, ..., g}.

Examples

>>> from pocketpartition import WithMaxGenus
>>> semigroups = list(WithMaxGenus(2))
>>> all(S.genus <= 2 for S in semigroups)
True
>>> {S.genus for S in semigroups} == {0, 1, 2}
True