def __getitem__(self, k): r""" Return the ``k``-th residue. INPUT: - ``k`` --- an integer between 1 and the length of the residue sequence ``self`` The ``k``-th residue is the ``e``-residue (see :meth:`sage.combinat.tableau.StandardTable.residue`) of the integer ``k`` in some standard tableaux. As the entries of standard tableaux are always between `1` and `n`, the size of the tableau, the integer ``k`` must also be in this range (that is, this is **not** 0-based!). EXAMPLES:: sage: from sage.combinat.tableau_residues import ResidueSequence sage: ResidueSequence(3,(0,0,1),[0,0,1,1,2,2,3,3])[4] 1 sage: ResidueSequence(3,(0,0,1),[0,0,1,1,2,2,3,3])[7] 0 sage: ResidueSequence(3,(0,0,1),[0,0,1,1,2,2,3,3])[9] Traceback (most recent call last): ... IndexError: k must be in the range 1, 2, ..., 8 """ try: return ClonableArray.__getitem__(self, k-1) except (IndexError, KeyError): raise IndexError('k must be in the range 1, 2, ..., {}'.format(len(self)))
def __getitem__(self, k): r""" Return the ``k``-th residue. INPUT: - ``k`` --- an integer between 1 and the length of the residue sequence ``self`` The ``k``-th residue is the ``e``-residue (see :meth:`sage.combinat.tableau.StandardTable.residue`) of the integer ``k`` in some standard tableaux. As the entries of standard tableaux are always between `1` and `n`, the size of the tableau, the integer ``k`` must also be in this range (that is, this is **not** 0-based!). EXAMPLES:: sage: from sage.combinat.tableau_residues import ResidueSequence sage: ResidueSequence(3,(0,0,1),[0,0,1,1,2,2,3,3])[4] 1 sage: ResidueSequence(3,(0,0,1),[0,0,1,1,2,2,3,3])[7] 0 sage: ResidueSequence(3,(0,0,1),[0,0,1,1,2,2,3,3])[9] Traceback (most recent call last): ... IndexError: k must be in the range 1, 2, ..., 8 """ try: return ClonableArray.__getitem__(self, k - 1) except (IndexError, KeyError): raise IndexError('k must be in the range 1, 2, ..., {}'.format(len(self)))
def __getitem__(self, idx): """ INPUT: - ``idx`` -- a valid path in ``self`` identifying a node .. NOTE:: The default implementation here assumes that the container of the node inherits from :class:`~sage.structure.list_clone.ClonableArray`. EXAMPLES:: sage: x = OrderedTree([[],[[]]]) sage: x[1,0] [] sage: x = OrderedTree([[],[[]]]) sage: x[()] [[], [[]]] sage: x[(0,)] [] sage: x[0,0] Traceback (most recent call last): ... IndexError: list index out of range """ if isinstance(idx, slice): return ClonableArray.__getitem__(self, idx) try: i = int(idx) except TypeError: res = self # idx is supposed to be an iterable of ints for i in idx: res = ClonableArray._getitem(res, i) return res else: return ClonableArray._getitem(self, i)
def __getitem__(self, idx): """ INPUT: - ``idx`` -- a valid path in ``self`` identifying a node .. NOTE:: The default implementation here assumes that the container of the node inherits from :class:`~sage.structure.list_clone.ClonableArray`. EXAMPLES:: sage: x = OrderedTree([[],[[]]]) sage: x[1,0] [] sage: x = OrderedTree([[],[[]]]) sage: x[()] [[], [[]]] sage: x[(0,)] [] sage: x[0,0] Traceback (most recent call last): ... IndexError: list index out of range """ if isinstance(idx, slice): return ClonableArray.__getitem__(self, idx) try: i = int(idx) except TypeError: res = self # idx is supposed to be an iterable of ints for i in idx: res = ClonableArray._getitem(res, i) return res else: return ClonableArray._getitem(self, i)