本文整理汇总了Python中sage.combinat.posets.posets.Poset.is_lattice方法的典型用法代码示例。如果您正苦于以下问题:Python Poset.is_lattice方法的具体用法?Python Poset.is_lattice怎么用?Python Poset.is_lattice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.combinat.posets.posets.Poset
的用法示例。
在下文中一共展示了Poset.is_lattice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LatticePoset
# 需要导入模块: from sage.combinat.posets.posets import Poset [as 别名]
# 或者: from sage.combinat.posets.posets.Poset import is_lattice [as 别名]
def LatticePoset(data, *args, **options):
r"""
Construct a lattice from various forms of input data.
INPUT:
- ``data``, ``*args``, ``**options`` -- data and options that will
be passed down to :func:`Poset` to construct a poset that is
also a lattice.
OUTPUT:
FiniteLatticePoset -- an instance of :class:`FiniteLatticePoset`
.. seealso:: :class:`Posets`, :class:`FiniteLatticePosets`, :func:`JoinSemiLattice`, :func:`MeetSemiLattice`
EXAMPLES:
Using data that defines a poset::
sage: LatticePoset([[1,2],[3],[3]])
Finite lattice containing 4 elements
sage: LatticePoset([[1,2],[3],[3]], cover_relations = True)
Finite lattice containing 4 elements
Using a previously constructed poset::
sage: P = Poset([[1,2],[3],[3]])
sage: L = LatticePoset(P); L
Finite lattice containing 4 elements
sage: type(L)
<class 'sage.combinat.posets.lattices.FiniteLatticePoset_with_category'>
If the data is not a lattice, then an error is raised::
sage: elms = [1,2,3,4,5,6,7]
sage: rels = [[1,2],[3,4],[4,5],[2,5]]
sage: LatticePoset((elms, rels))
Traceback (most recent call last):
...
ValueError: Not a lattice.
Creating a facade lattice::
sage: L = LatticePoset([[1,2],[3],[3]], facade = True)
sage: L.category()
Category of facade finite lattice posets
sage: parent(L[0])
Integer Ring
sage: TestSuite(L).run(skip = ['_test_an_element']) # is_parent_of is not yet implemented
"""
if isinstance(data,FiniteLatticePoset) and len(args) == 0 and len(options) == 0:
return data
P = Poset(data, *args, **options)
if not P.is_lattice():
raise ValueError, "Not a lattice."
return FiniteLatticePoset(P, category = FiniteLatticePosets(), facade = P._is_facade)