예제 #1
0
파일: core.py 프로젝트: biasse/sage
    def __init__(self, core, parent):
        """
        TESTS::

            sage: C = Cores(4,3)
            sage: c = C([2,1]); c
            [2, 1]
            sage: type(c)
            <class 'sage.combinat.core.Cores_length_with_category.element_class'>
            sage: c.parent()
            4-Cores of length 3
            sage: TestSuite(c).run()

            sage: C = Cores(3,3)
            sage: C([2,1])
            Traceback (most recent call last):
            ...
            ValueError: [2, 1] is not a 3-core
        """
        k = parent.k
        part = Partition(core)
        if not part.is_core(k):
            raise ValueError, "%s is not a %s-core" % (part, k)
        CombinatorialObject.__init__(self, core)
        Element.__init__(self, parent)
예제 #2
0
파일: core.py 프로젝트: biasse/sage
    def __init__(self, core, parent):
        """
        TESTS::

            sage: C = Cores(4,3)
            sage: c = C([2,1]); c
            [2, 1]
            sage: type(c)
            <class 'sage.combinat.core.Cores_length_with_category.element_class'>
            sage: c.parent()
            4-Cores of length 3
            sage: TestSuite(c).run()

            sage: C = Cores(3,3)
            sage: C([2,1])
            Traceback (most recent call last):
            ...
            ValueError: [2, 1] is not a 3-core
        """
        k = parent.k
        part = Partition(core)
        if not part.is_core(k):
            raise ValueError, "%s is not a %s-core"%(part, k)
        CombinatorialObject.__init__(self, core)
        Element.__init__(self, parent)
예제 #3
0
    def __init__(self, parent, t):
        r"""
        Initialize a composition tableau.

        TESTS::

            sage: t = CompositionTableaux()([[1],[2,2]])
            sage: s = CompositionTableaux(3)([[1],[2,2]])
            sage: s==t
            True
            sage: t.parent()
            Composition Tableaux
            sage: s.parent()
            Composition Tableaux of size 3 and maximum entry 3
            sage: r = CompositionTableaux()(s)
            sage: r.parent()
            Composition Tableaux
        """
        if isinstance(t, CompositionTableau):
            Element.__init__(self, parent)
            CombinatorialObject.__init__(self, t._list)
            return

        # CombinatorialObject verifies that t is a list
        # We must verify t is a list of lists
        if not all(isinstance(row, list) for row in t):
            raise ValueError("A composition tableau must be a list of lists.")

        if not map(len, t) in Compositions():
            raise ValueError(
                "A composition tableau must be a list of non-empty lists.")

        # Verify rows weakly decrease from left to right
        for row in t:
            if any(row[i] < row[i + 1] for i in range(len(row) - 1)):
                raise ValueError(
                    "Rows must weakly decrease from left to right.")

        # Verify leftmost column strictly increases from top to bottom
        first_col = [row[0] for row in t if t != [[]]]
        if any(first_col[i] >= first_col[i + 1] for i in range(len(t) - 1)):
            raise ValueError(
                "Leftmost column must strictly increase from top to bottom.")

        # Verify triple condition
        l = len(t)
        m = max(map(len, t) + [0])
        TT = [row + [0] * (m - len(row)) for row in t]
        for i in range(l):
            for j in range(i + 1, l):
                for k in range(1, m):
                    if TT[j][k] != 0 and TT[j][k] >= TT[i][k] and TT[j][
                            k] <= TT[i][k - 1]:
                        raise ValueError("Triple condition must be satisfied.")

        Element.__init__(self, parent)
        CombinatorialObject.__init__(self, t)
    def __init__(self, lst):
        """
        TESTS::

            sage: ParkingFunction([1, 1, 2, 2, 5, 6])
            [1, 1, 2, 2, 5, 6]
        """
        if not is_a(lst):
            raise ValueError("%s is not a parking function." % lst)
        CombinatorialObject.__init__(self, lst)
예제 #5
0
    def __init__(self, lst):
        """
        TESTS::

            sage: ParkingFunction([1, 1, 2, 2, 5, 6])
            [1, 1, 2, 2, 5, 6]
        """
        if not is_a(lst):
            raise ValueError("%s is not a parking function." % lst)
        CombinatorialObject.__init__(self, lst)
    def __init__(self, parent, vecpar):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: elt =  VectorPartition([[3, 2, 1], [2, 2, 1]])
            sage: TestSuite(elt).run()
        """
        CombinatorialObject.__init__(self, sorted(vecpar))
        Element.__init__(self, parent)
예제 #7
0
    def __init__(self, parent, tau):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: elt =  SimilarityClassType([[3, [3, 2, 1]], [2, [2, 1]]])
            sage: TestSuite(elt).run()
        """
        CombinatorialObject.__init__(self, sorted(tau, key=lambda PT: (PT.degree(), PT.partition())))
        Element.__init__(self, parent)
예제 #8
0
    def __init__(self, parent, x):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: mst = MultiSkewTableau([ [[None,1],[2,3]], [[1,2],[2]] ])
            sage: TestSuite(mst).run()
        """
        CombinatorialObject.__init__(self, x)
        Element.__init__(self, parent)
예제 #9
0
    def __init__(self, parent, x):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: mst = MultiSkewTableau([ [[None,1],[2,3]], [[1,2],[2]] ])
            sage: TestSuite(mst).run()
        """
        CombinatorialObject.__init__(self, x)
        Element.__init__(self, parent)
예제 #10
0
    def __init__(self, parent, vecpar):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: elt =  VectorPartition([[3, 2, 1], [2, 2, 1]])
            sage: TestSuite(elt).run()
        """
        CombinatorialObject.__init__(self, sorted(vecpar))
        Element.__init__(self, parent)
예제 #11
0
    def __init__(self, parent, tau):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: elt =  SimilarityClassType([[3, [3, 2, 1]], [2, [2, 1]]])
            sage: TestSuite(elt).run()
        """
        CombinatorialObject.__init__(
            self, sorted(tau, key=lambda PT: (PT.degree(), PT.partition())))
        Element.__init__(self, parent)
예제 #12
0
    def __init__(self, parent, lst):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: D = Derangements(4)
            sage: elt = D([4,3,2,1])
            sage: TestSuite(elt).run()
        """
        CombinatorialObject.__init__(self, lst)
        Element.__init__(self, parent)
예제 #13
0
    def __init__(self, parent, t):
        r"""
        Initialize a composition tableau.

        TESTS::

            sage: t = CompositionTableaux()([[1],[2,2]])
            sage: s = CompositionTableaux(3)([[1],[2,2]])
            sage: s==t
            True
            sage: t.parent()
            Composition Tableaux
            sage: s.parent()
            Composition Tableaux of size 3 and maximum entry 3
            sage: r = CompositionTableaux()(s)
            sage: r.parent()
            Composition Tableaux
        """
        if isinstance(t, CompositionTableau):
            Element.__init__(self, parent)
            CombinatorialObject.__init__(self, t._list)
            return

        # CombinatorialObject verifies that t is a list
        # We must verify t is a list of lists
        if not all(isinstance(row, list) for row in t):
            raise ValueError("A composition tableau must be a list of lists.")

        if not map(len,t) in Compositions():
            raise ValueError("A composition tableau must be a list of non-empty lists.")

        # Verify rows weakly decrease from left to right
        for row in t:
            if any(row[i] < row[i+1] for i in range(len(row)-1)):
                raise ValueError("Rows must weakly decrease from left to right.")

        # Verify leftmost column strictly increases from top to bottom
        first_col = [row[0] for row in t if t!=[[]]]
        if any(first_col[i] >= first_col[i+1] for i in range(len(t)-1)):
            raise ValueError("Leftmost column must strictly increase from top to bottom.")

        # Verify triple condition
        l = len(t)
        m = max(map(len,t)+[0])
        TT = [row+[0]*(m-len(row)) for row in t]
        for i in range(l):
            for j in range(i+1,l):
                for k in range(1,m):
                    if TT[j][k] != 0 and TT[j][k] >= TT[i][k] and TT[j][k] <= TT[i][k-1]:
                        raise ValueError("Triple condition must be satisfied.")

        Element.__init__(self, parent)
        CombinatorialObject.__init__(self, t)
예제 #14
0
파일: derangements.py 프로젝트: bukzor/sage
    def __init__(self, parent, lst):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: D = Derangements(4)
            sage: elt = D([4,3,2,1])
            sage: TestSuite(elt).run()
        """
        CombinatorialObject.__init__(self, lst)
        Element.__init__(self, parent)
 def __init__(self,parent,data):
     i = len(data)-1
     while i >= 0 and len(data[i]) == 0:
         data.pop()
         i -= 1
     self.rows = len(data)
     if data == []:
         self.cols = 0
     else:
         self.cols = max([len(r) for r in data])
     self.data = data
     CombinatorialObject.__init__(self, data)
     Element.__init__(self, parent)
예제 #16
0
    def __init__(self, shape=None, rigging_list=None, vacancy_nums=None):
        r"""
        Initialize by the rigged partition.

        Note that this only performs checks to see that the sizes match up.

        INPUT:

        - ``shape`` -- (Default: ``None``) The shape

        - ``rigging_list`` -- (Default: ``None``) The riggings

        - ``vacancy_nums`` -- (Default: ``None``) The vacancy numbers

        TESTS::

            sage: sage.combinat.rigged_configurations.rigged_partition.RiggedPartition()
            (/)
            <BLANKLINE>
            sage: RP = sage.combinat.rigged_configurations.rigged_partition.RiggedPartition([2,1], [0,0], [1, 0])
            sage: RP
            1[ ][ ]0
            0[ ]0
            <BLANKLINE>
            sage: TestSuite(RP).run()
        """
        if shape is None:
            CombinatorialObject.__init__(self, [])
            self.vacancy_numbers = []
            self.rigging = []
        else:
            CombinatorialObject.__init__(self, shape)

            if vacancy_nums is not None:
                if len(shape) != len(vacancy_nums):
                    raise ValueError(
                        "Mismatch between shape and vacancy numbers")

                self.vacancy_numbers = list(vacancy_nums)
            else:
                self.vacancy_numbers = [None] * len(shape)

            if rigging_list is not None:

                if len(shape) != len(rigging_list):
                    raise ValueError("Mismatch between shape and rigging list")

                self.rigging = list(rigging_list)
            else:
                self.rigging = [None] * len(shape)
예제 #17
0
    def __init__(self, parent, list):
        """
        EXAMPLES::

            sage: from sage.combinat.crystals.tensor_product import ImmutableListWithParent, TestParent
            sage: l = ImmutableListWithParent(TestParent(), [1,2,3])
            sage: l.parent()
            A parent for tests
            sage: parent(l)
            A parent for tests
            sage: TestSuite(l).run(skip = "_test_category")
        """
        Element.__init__(self, parent)
        CombinatorialObject.__init__(self, list)
예제 #18
0
    def __init__(self, parent, list):
        """
        EXAMPLES::

            sage: from sage.combinat.crystals.tensor_product import ImmutableListWithParent, TestParent
            sage: l = ImmutableListWithParent(TestParent(), [1,2,3])
            sage: l.parent()
            A parent for tests
            sage: parent(l)
            A parent for tests
            sage: TestSuite(l).run(skip = "_test_category")
        """
        Element.__init__(self, parent)
        CombinatorialObject.__init__(self, list)
예제 #19
0
    def __init__(self, shape=None, rigging_list=None, vacancy_nums=None):
        r"""
        Initialize by the rigged partition.

        Note that this only performs checks to see that the sizes match up.

        INPUT:

        - ``shape`` -- (Default: ``None``) The shape

        - ``rigging_list`` -- (Default: ``None``) The riggings

        - ``vacancy_nums`` -- (Default: ``None``) The vacancy numbers

        TESTS::

            sage: sage.combinat.rigged_configurations.rigged_partition.RiggedPartition()
            (/)
            <BLANKLINE>
            sage: RP = sage.combinat.rigged_configurations.rigged_partition.RiggedPartition([2,1], [0,0], [1, 0])
            sage: RP
            1[ ][ ]0
            0[ ]0
            <BLANKLINE>
            sage: TestSuite(RP).run()
        """
        if shape is None:
            CombinatorialObject.__init__(self, [])
            self.vacancy_numbers = []
            self.rigging = []
        else:
            CombinatorialObject.__init__(self, shape)

            if vacancy_nums is not None:
                if len(shape) != len(vacancy_nums):
                    raise ValueError("Mismatch between shape and vacancy numbers")

                self.vacancy_numbers = list(vacancy_nums)
            else:
                self.vacancy_numbers = [None] * len(shape)

            if rigging_list is not None:

                if len(shape) != len(rigging_list):
                    raise ValueError("Mismatch between shape and rigging list")

                self.rigging = list(rigging_list)
            else:
                self.rigging = [None] * len(shape)
예제 #20
0
 def __init__(self, parent, labels, list):
     """
     EXAMPLES::
     
         sage: from sage.combinat.species.structure import GenericSpeciesStructure
         sage: a = GenericSpeciesStructure(None, [2,3,4], [1,2,3])
         sage: a
         [2, 3, 4]
         sage: a.parent() is None
         True
         sage: a == loads(dumps(a))
         True
     """
     self._parent = parent
     self._labels = labels
     CombinatorialObject.__init__(self, list)
예제 #21
0
    def __init__(self,parent,data):
        r"""
        EXAMPLES::

            sage: Y = CrystalOfGeneralizedYoungWalls(2)
            sage: mg = Y.module_generators[0]
            sage: TestSuite(mg).run()
        """
        i = len(data)-1
        while i >= 0 and len(data[i]) == 0:
            data.pop()
            i -= 1
        self.rows = len(data)
        if data == []:
            self.cols = 0
        else:
            self.cols = max([len(r) for r in data])
        self.data = data
        CombinatorialObject.__init__(self, data)
        Element.__init__(self, parent)
예제 #22
0
    def __init__(self, parent, data):
        r"""
        EXAMPLES::

            sage: Y = InfinityCrystalOfGeneralizedYoungWalls(2)
            sage: mg = Y.module_generators[0]
            sage: TestSuite(mg).run()
        """
        i = len(data) - 1
        while i >= 0 and len(data[i]) == 0:
            data.pop()
            i -= 1
        self.rows = len(data)
        if data == []:
            self.cols = 0
        else:
            self.cols = max([len(r) for r in data])
        self.data = data
        CombinatorialObject.__init__(self, data)
        Element.__init__(self, parent)