当前位置: 首页>>代码示例>>Python>>正文


Python posets.Poset类代码示例

本文整理汇总了Python中sage.combinat.posets.posets.Poset的典型用法代码示例。如果您正苦于以下问题:Python Poset类的具体用法?Python Poset怎么用?Python Poset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Poset类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: random_element

    def random_element(self):
        r"""
        Return a uniformly random element of ``self``.

        ALGORITHM:

        This uses the
        :meth:`~sage.combinat.posets.posets.FinitePoset.random_order_ideal`
        method and the natural bijection with plane partitions.

        EXAMPLES::

            sage: P = PlanePartitions((4,3,5))
            sage: P.random_element()
            Plane partition [[4, 3, 3], [4, 0, 0], [2, 0, 0], [0, 0, 0]]
        """
        def leq(thing1, thing2):
            return all(thing1[i] <= thing2[i] for i in range(len(thing1)))
        elem = [(i,j,k) for i in range(self._box[0]) for j in range(self._box[1])
                for k in range(self._box[2])]
        myposet = Poset((elem, leq))
        R = myposet.random_order_ideal()
        Z = [[0 for i in range(self._box[1])] for j in range(self._box[0])]
        for C in R:
            Z[C[0]][C[1]] += 1
        return self.element_class(self, Z, check=False)
开发者ID:mcognetta,项目名称:sage,代码行数:26,代码来源:plane_partition.py

示例2: LatticePoset

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)
开发者ID:pombredanne,项目名称:sage-1,代码行数:60,代码来源:lattices.py

示例3: green_classes

        def green_classes(self, side = "twosided"):
            r"""
            INPUT:

             - ``side`` -- "left", "right", or "twosided"

            Depending on the value of ``side``, returns respectively
            the `L`-classes, `R`-classes, or `J`-classes of ``self``,
            sorted decreasingly along a linear extension of
            respectively `L`, `R` or `J`-order.

            EXAMPLES::

                sage: M = Semigroups().Finite().example(('a','b')); M
                An example of a finite semigroup: the left regular band generated by ('a', 'b')
                sage: M.green_classes()
                [{'a'}, {'b'}, {'ab', 'ba'}]
                sage: M.green_classes(side="left")
                [{'a'}, {'b'}, {'ab', 'ba'}]
                sage: M.green_classes(side="right")
                [{'b'}, {'a'}, {'ab'}, {'ba'}]
            """
            G = self.cayley_graph_cached(side=side, simple=True).strongly_connected_components_digraph()
            from sage.combinat.posets.posets import Poset
            P = Poset(G, facade = True)
            return P.linear_extension()
开发者ID:nthiery,项目名称:sage-semigroups,代码行数:26,代码来源:finite_semigroups.py

示例4: composition_series_poset

        def composition_series_poset(self, side = 'right'):
            """
            Experimental, and apparently broken ...

            EXAMPLES::

                sage: S = Monoids().Aperiodic().Finite().example(5); S
                The finite H-trivial monoid of order preserving maps on {1, 2, 3, 4, 5}
                sage: P = S.composition_series_poset(side = 'right')
                sage: list(P)
                [4, 3, 2, 1, 0]
                sage: P.cover_relations()
                []
                sage: P = S.composition_series_poset(side = 'left')
                sage: list(P)
                [4, 3, 2, 1, 0]
                sage: P.cover_relations()
            """
            from sage.combinat.posets.posets import Poset
            Js = self.regular_j_classes_keys()
            principal_order_filters = {}
            for J in Js:
                R = self.lr_regular_class_module(J, side=side)
                principal_order_filters[J] = R.composition_series()
                import time
                print "%s  %s: %s %s %s"%(time.strftime("%H:%M:%S"), J, self.simple_module_dimension(J), R.dimension(), principal_order_filters[J])
            P = Poset( ( Js, lambda J1, J2: J2 in principal_order_filters[J1] ), facade = True )
            from sage.sets.set import Set
            assert all( Set( P.principal_order_filter(J) ) == principal_order_filters[J]
                        for J in Js )
            return P
开发者ID:nthiery,项目名称:sage-semigroups,代码行数:31,代码来源:finite_h_trivial_semigroups.py

示例5: to_poset

    def to_poset(self, root_to_leaf = False):
        r"""
        Return the poset obtained by interpreting the tree as a hasse
        diagram. The default orientation is from leaves to root but you can
        pass ``root_to_leaf=True`` to obtain the inverse orientation.

        INPUT:

        - ``root_to_leaf`` -- boolean, true if the poset orientation should
          be from root to leaves. It is false by default.

        EXAMPLES::

            sage: t = OrderedTree([])
            sage: t.to_poset()
            Finite poset containing 1 elements
            sage: p = OrderedTree([[[]],[],[]]).to_poset()
            sage: p.cover_relations()
            [[3, 4], [2, 4], [0, 1], [1, 4]]
            sage: p = OrderedTree([[[]],[],[]]).to_poset(root_to_leaf=True)
            sage: p.cover_relations()
            [[0, 1], [0, 2], [0, 3], [3, 4]]

        If the tree is labelled, we use its labelling to label the poset.
        Otherwise, we use the poset canonical labelling::

            sage: t = OrderedTree([[[]],[],[]]).canonical_labelling()
            sage: t
            1[2[3[]], 4[], 5[]]
            sage: t.to_poset().cover_relations()
            [[5, 1], [4, 1], [3, 2], [2, 1]]
        """
        if self in LabelledOrderedTrees():
            relabel = False
        else:
            self = self.canonical_labelling()
            relabel = True
        relations = []
        elements = [self.label()]
        roots = [self]
        while len(roots)!=0:
            node = roots.pop()
            for child in node:
                elements.append(child.label())
                relations.append((node.label(),child.label()) if root_to_leaf else (child.label(),node.label()))
                roots.append(child)
        from sage.combinat.posets.posets import Poset
        p = Poset([elements, relations])
        if relabel:
            p = p.canonical_label()
        return p
开发者ID:bukzor,项目名称:sage,代码行数:51,代码来源:ordered_tree.py

示例6: MeetSemilattice

def MeetSemilattice(data, *args, **options):
    r"""
    Construct a meet semi-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 meet semilattice.

    .. seealso:: :func:`Poset`, :func:`JoinSemilattice`, :func:`LatticePoset`

    EXAMPLES:

    Using data that defines a poset::

          sage: MeetSemilattice([[1,2],[3],[3]])
          Finite meet-semilattice containing 4 elements

          sage: MeetSemilattice([[1,2],[3],[3]], cover_relations = True)
          Finite meet-semilattice containing 4 elements

    Using a previously constructed poset::

          sage: P = Poset([[1,2],[3],[3]])
          sage: L = MeetSemilattice(P); L
          Finite meet-semilattice containing 4 elements
          sage: type(L)
          <class 'sage.combinat.posets.lattices.FiniteMeetSemilattice_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: MeetSemilattice((elms, rels))
          Traceback (most recent call last):
          ...
          ValueError: Not a meet semilattice.
    """
    if isinstance(data,FiniteMeetSemilattice) and len(args) == 0 and len(options) == 0:
        return data
    P = Poset(data, *args, **options)
    if not P.is_meet_semilattice():
        raise ValueError, "Not a meet semilattice."
    return FiniteMeetSemilattice(P)
开发者ID:bgxcpku,项目名称:sagelib,代码行数:45,代码来源:lattices.py

示例7: __init__

    def __init__(self):
        r"""
        Container for all possible analytic types of forms and/or spaces.

        This class is supposed to be used as a Singleton.

        It first creates a ``Poset`` that contains all basic analytic
        properties to be modeled by the AnalyticType. Then the order
        ideals lattice of that Poset is taken as the underlying
        FiniteLatticePoset of ``self``.

        In particular elements of ``self`` describe what basic analytic
        properties are contained/included in that element.

        EXAMPLES::

            sage: AT = AnalyticType()
            sage: AT
            Analytic Type
            sage: isinstance(AT, FiniteLatticePoset)
            True

            sage: AT.is_lattice()
            True
            sage: AT.is_finite()
            True
            sage: AT.cardinality()
            10
            sage: AT.is_modular()
            True
            sage: AT.is_bounded()
            True
            sage: AT.is_distributive()
            True
            sage: AT.list()
            [zero,
             zero,
             cuspidal,
             modular,
             weakly holomorphic modular,
             quasi cuspidal,
             quasi modular,
             quasi weakly holomorphic modular,
             meromorphic modular,
             quasi meromorphic modular]
            sage: len(AT.relations())
            45
            sage: AT.cover_relations()
            [[zero, zero],
             [zero, cuspidal],
             [zero, quasi cuspidal],
             [cuspidal, modular],
             [cuspidal, quasi cuspidal],
             [modular, weakly holomorphic modular],
             [modular, quasi modular],
             [weakly holomorphic modular, quasi weakly holomorphic modular],
             [weakly holomorphic modular, meromorphic modular],
             [quasi cuspidal, quasi modular],
             [quasi modular, quasi weakly holomorphic modular],
             [quasi weakly holomorphic modular, quasi meromorphic modular],
             [meromorphic modular, quasi meromorphic modular]]
            sage: AT.has_top()
            True
            sage: AT.has_bottom()
            True
            sage: AT.top()
            quasi meromorphic modular
            sage: AT.bottom()
            zero
        """

        # We (arbitrarily) choose to model by inclusion instead of restriction
        P_elements = [ "cusp", "holo", "weak", "mero", "quasi"]
        P_relations = [["cusp", "holo"], ["holo", "weak"], ["weak", "mero"]]
        
        self._base_poset = Poset([P_elements, P_relations], cover_relations=True, facade=False)
        L = self._base_poset.order_ideals_lattice()
        L = FiniteLatticePoset(L, facade=False)

        FiniteLatticePoset.__init__(self, hasse_diagram=L._hasse_diagram, elements=L._elements, category=L.category(), facade=L._is_facade, key=None)
开发者ID:jjermann,项目名称:hecke_mf,代码行数:80,代码来源:analytic_type.py

示例8: AnalyticType

class AnalyticType(FiniteLatticePoset):
    r"""
    Container for all possible analytic types of forms and/or spaces

    The ``analytic type`` of forms spaces or rings describes all possible
    occuring basic ``analytic properties`` of elements in the space/ring
    (or more).

    For ambient spaces/rings this means that all elements with those properties
    (and the restrictions of the space/ring) are contained in the space/ring.

    The analytic type of an element is the analytic type of its minimal
    ambient space/ring.

    The basic ``analytic properties`` are:

        - ``quasi``  - Whether the element is quasi modular (and not modular)
                       or modular.
        - ``mero``   - ``meromorphic``: If the element is meromorphic
                       and meromorphic at infinity.
        - ``weak``   - ``weakly holomorphic``: If the element is holomorphic
                       and meromorphic at infinity.
        - ``holo``   - ``holomorphic``: If the element is holomorphic and
                       holomorphic at infinity.
        - ``cusp``   - ``cuspidal``: If the element additionally has a positive
                       order at infinity.

    The ``zero`` elements/property have no analytic properties (or only ``quasi``).

    For ring elements the property describes whether one of its homogeneous
    components satisfies that property and the "union" of those properties
    is returned as the ``analytic type``.

    Similarly for quasi forms the property describes whether one of its
    quasi components satisfies that property.

    There is a (natural) partial order between the basic properties
    (and analytic types) given by "inclusion". We name the analytic type
    according to its maximal analytic properties.

    EXAMPLES::

    For n=3 the quasi form ``el = E6 - E2^3`` has the quasi components ``E6``
    which is ``holomorphic`` and ``E2^3`` which is ``quasi holomorphic``.
    So the analytic type of ``el`` is ``quasi holomorphic`` despite the fact
    that the sum (``el``) describes a function which is zero at infinity.
 
        sage: from space import QModularForms
        sage: x,y,z,d = var("x,y,z,d")
        sage: el = QModularForms(group=3, k=6, ep=-1)(y-z^3)
        sage: el.analytic_type()
        quasi modular

    Similarly the type of the ring element ``el2 = E4/Delta - E6/Delta`` is
    ``weakly holomorphic`` despite the fact that the sum (``el2``) describes
    a function which is holomorphic at infinity.

        sage: from graded_ring import WeakModularFormsRing
        sage: x,y,z,d = var("x,y,z,d")
        sage: el2 = WeakModularFormsRing(group=3)(x/(x^3-y^2)-y/(x^3-y^2))
        sage: el2.analytic_type()
        weakly holomorphic modular
    """

    Element = AnalyticTypeElement

    @staticmethod
    def __classcall__(cls):
        r"""
        Directly return the classcall of UniqueRepresentation
        (skipping the classcalls of the other superclasses).

        That's because ``self`` is supposed to be used as a Singleton.
        It initializes the FinitelatticePoset with the proper arguments
        by itself in ``self.__init__()``.

        EXAMPLES::

            sage: AT = AnalyticType()
            sage: AT2 = AnalyticType()
            sage: AT == AT2
            True
        """

        return super(FinitePoset, cls).__classcall__(cls)
                
    def __init__(self):
        r"""
        Container for all possible analytic types of forms and/or spaces.

        This class is supposed to be used as a Singleton.

        It first creates a ``Poset`` that contains all basic analytic
        properties to be modeled by the AnalyticType. Then the order
        ideals lattice of that Poset is taken as the underlying
        FiniteLatticePoset of ``self``.

        In particular elements of ``self`` describe what basic analytic
        properties are contained/included in that element.

#.........这里部分代码省略.........
开发者ID:jjermann,项目名称:hecke_mf,代码行数:101,代码来源:analytic_type.py


注:本文中的sage.combinat.posets.posets.Poset类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。