def __init__(self, crystals, facade, keepkey, category, **options): """ TESTS:: sage: C = crystals.Letters(['A',2]) sage: B = crystals.DirectSum([C,C], keepkey=True) sage: B Direct sum of the crystals Family (The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2]) sage: B.cartan_type() ['A', 2] sage: from sage.combinat.crystals.direct_sum import DirectSumOfCrystals sage: isinstance(B, DirectSumOfCrystals) True """ if facade: Parent.__init__(self, facade=tuple(crystals), category=category) else: Parent.__init__(self, category=category) DisjointUnionEnumeratedSets.__init__(self, crystals, keepkey=keepkey, facade=facade) self.rename("Direct sum of the crystals {}".format(crystals)) self._keepkey = keepkey self.crystals = crystals if len(crystals) == 0: raise ValueError("The direct sum is empty") else: assert(crystal.cartan_type() == crystals[0].cartan_type() for crystal in crystals) self._cartan_type = crystals[0].cartan_type() if keepkey: self.module_generators = [ self(tuple([i,b])) for i in range(len(crystals)) for b in crystals[i].module_generators ] else: self.module_generators = sum( (list(B.module_generators) for B in crystals), [])
def __init__(self): """ TESTS:: sage: from sage.combinat.ordered_tree import OrderedTrees_all sage: B = OrderedTrees_all() sage: B.cardinality() +Infinity sage: it = iter(B) sage: (next(it), next(it), next(it), next(it), next(it)) ([], [[]], [[], []], [[[]]], [[], [], []]) sage: next(it).parent() Ordered trees sage: B([]) [] sage: B is OrderedTrees_all() True sage: TestSuite(B).run() # long time """ DisjointUnionEnumeratedSets.__init__(self, Family(NonNegativeIntegers(), OrderedTrees_size), facade=True, keepkey=False)
def __init__(self, weights): """ TESTS:: sage: C = WeightedIntegerVectors([2,1,3]) sage: C.__class__ <class 'sage.combinat.integer_vector_weighted.WeightedIntegerVectors_all_with_category'> sage: C.category() Join of Category of sets with grading and Category of infinite enumerated sets sage: TestSuite(C).run() """ self._weights = weights from sage.sets.all import Family, NonNegativeIntegers # Use "partial" to make the basis function (with the weights # argument specified) pickleable. Otherwise, it seems to # cause problems... from functools import partial F = Family(NonNegativeIntegers(), partial(WeightedIntegerVectors, weight=weights)) DisjointUnionEnumeratedSets.__init__( self, F, facade=True, keepkey=False, category=(SetsWithGrading(), InfiniteEnumeratedSets()))
def __init__(self, **keywords): DisjointUnionEnumeratedSets.__init__( self, Family(NonNegativeIntegers(), lambda i: Relations_size(i, **keywords)), facade=True, keepkey=False, category=(Posets(), EnumeratedSets())) self._sign = None self._initialise_properties(keywords)
def __init__(self, max_entry=None): r""" Initialize ``self``. TESTS:: sage: CT = CompositionTableaux() sage: TestSuite(CT).run() """ self.max_entry = max_entry CT_n = lambda n: CompositionTableaux_size(n, max_entry) DisjointUnionEnumeratedSets.__init__(self, Family(NonNegativeIntegers(), CT_n), facade=True, keepkey = False)
def __init__(self): """ TESTS:: sage: sum(x**len(t) for t in ....: set(RootedTree(t) for t in OrderedTrees(6))) x^5 + x^4 + 3*x^3 + 6*x^2 + 9*x sage: sum(x**len(t) for t in RootedTrees(6)) x^5 + x^4 + 3*x^3 + 6*x^2 + 9*x sage: TestSuite(RootedTrees()).run() # long time """ DisjointUnionEnumeratedSets.__init__( self, Family(NonNegativeIntegers(), RootedTrees_size), facade=True, keepkey=False)
def __init__(self, n=None): r""" EXAMPLES:: sage: from sage.combinat.baxter_permutations import BaxterPermutations_all sage: BaxterPermutations_all() Baxter permutations """ self.element_class = Permutations().element_class from sage.categories.examples.infinite_enumerated_sets import NonNegativeIntegers from sage.sets.family import Family DisjointUnionEnumeratedSets.__init__(self, Family(NonNegativeIntegers(), BaxterPermutations_size), facade=False, keepkey=False)
def __init__(self, crystals, **options): """ TESTS:: sage: C = crystals.Letters(['A',2]) sage: B = crystals.DirectSum([C,C], keepkey=True) sage: B Direct sum of the crystals Family (The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2]) sage: B.cartan_type() ['A', 2] sage: from sage.combinat.crystals.direct_sum import DirectSumOfCrystals sage: isinstance(B, DirectSumOfCrystals) True """ if 'keepkey' in options: keepkey = options['keepkey'] else: keepkey = False # facade = options['facade'] if keepkey: facade = False else: facade = True category = Category.meet( [Category.join(crystal.categories()) for crystal in crystals]) Parent.__init__(self, category=category) DisjointUnionEnumeratedSets.__init__(self, crystals, keepkey=keepkey, facade=facade) self.rename("Direct sum of the crystals %s" % (crystals, )) self._keepkey = keepkey self.crystals = crystals if len(crystals) == 0: raise ValueError("The direct sum is empty") else: assert (crystal.cartan_type() == crystals[0].cartan_type() for crystal in crystals) self._cartan_type = crystals[0].cartan_type() if keepkey: self.module_generators = [ self(tuple([i, b])) for i in range(len(crystals)) for b in crystals[i].module_generators ] else: self.module_generators = sum( (list(B.module_generators) for B in crystals), [])
def __init__(self, n): r""" Initializes the class of all standard super tableaux of size ``n``. TESTS:: sage: TestSuite( StandardSuperTableaux(4) ).run() """ StandardSuperTableaux.__init__(self) from sage.combinat.partition import Partitions_n DisjointUnionEnumeratedSets.__init__(self, Family(Partitions_n(n), StandardSuperTableaux_shape), category=FiniteEnumeratedSets(), facade=True, keepkey=False) self.size = Integer(n)
def __init__(self): r""" Initializes the class of all standard super tableaux. TESTS:: sage: from sage.combinat.super_tableau import StandardSuperTableaux_all sage: SST = StandardSuperTableaux_all(); SST Standard super tableaux sage: TestSuite(SST).run() """ StandardSuperTableaux.__init__(self) DisjointUnionEnumeratedSets.__init__(self, Family(NonNegativeIntegers(), StandardSuperTableaux_size), facade=True, keepkey=False)
def __init__(self, weight): """ TESTS:: sage: C = WeightedIntegerVectors([2,1,3]) sage: C.category() Category of facade infinite enumerated sets with grading sage: TestSuite(C).run() """ self._weights = weight from sage.sets.all import Family, NonNegativeIntegers # Use "partial" to make the basis function (with the weights # argument specified) pickleable. Otherwise, it seems to # cause problems... from functools import partial F = Family(NonNegativeIntegers(), partial(WeightedIntegerVectors, weight=weight)) cat = (SetsWithGrading(), InfiniteEnumeratedSets()) DisjointUnionEnumeratedSets.__init__(self, F, facade=True, keepkey=False, category=cat)
def __init__(self, crystals, **options): """ TESTS:: sage: C = CrystalOfLetters(['A',2]) sage: B = DirectSumOfCrystals([C,C], keepkey=True) sage: B Direct sum of the crystals Family (The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2]) sage: B.cartan_type() ['A', 2] sage: isinstance(B, DirectSumOfCrystals) True """ if options.has_key('keepkey'): keepkey = options['keepkey'] else: keepkey = False # facade = options['facade'] if keepkey: facade = False else: facade = True category = Category.meet([Category.join(crystal.categories()) for crystal in crystals]) Parent.__init__(self, category = category) DisjointUnionEnumeratedSets.__init__(self, crystals, keepkey = keepkey, facade = facade) self.rename("Direct sum of the crystals %s"%(crystals,)) self._keepkey = keepkey self.crystals = crystals if len(crystals) == 0: raise ValueError, "The direct sum is empty" else: assert(crystal.cartan_type() == crystals[0].cartan_type() for crystal in crystals) self._cartan_type = crystals[0].cartan_type() if keepkey: self.module_generators = [ self(tuple([i,b])) for i in range(len(crystals)) for b in crystals[i].module_generators ] else: self.module_generators = sum( (list(B.module_generators) for B in crystals), [])
def __init__(self, crystals, facade, keepkey, category, **options): """ TESTS:: sage: C = crystals.Letters(['A',2]) sage: B = crystals.DirectSum([C,C], keepkey=True) sage: B Direct sum of the crystals Family (The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2]) sage: B.cartan_type() ['A', 2] sage: from sage.combinat.crystals.direct_sum import DirectSumOfCrystals sage: isinstance(B, DirectSumOfCrystals) True """ DisjointUnionEnumeratedSets.__init__(self, crystals, keepkey=keepkey, facade=facade, category=category) self.rename("Direct sum of the crystals {}".format(crystals)) self._keepkey = keepkey self.crystals = crystals if len(crystals) == 0: raise ValueError("the direct sum is empty") else: assert (crystal.cartan_type() == crystals[0].cartan_type() for crystal in crystals) self._cartan_type = crystals[0].cartan_type() if keepkey: self.module_generators = tuple([ self((i, b)) for i, B in enumerate(crystals) for b in B.module_generators ]) else: self.module_generators = sum( (tuple(B.module_generators) for B in crystals), ())
def __init__(self): """ TESTS:: sage: from sage.combinat.ordered_tree import OrderedTrees_all sage: B = OrderedTrees_all() sage: B.cardinality() +Infinity sage: it = iter(B) sage: (next(it), next(it), next(it), next(it), next(it)) ([], [[]], [[], []], [[[]]], [[], [], []]) sage: next(it).parent() Ordered trees sage: B([]) [] sage: B is OrderedTrees_all() True sage: TestSuite(B).run() # long time """ DisjointUnionEnumeratedSets.__init__( self, Family(NonNegativeIntegers(), OrderedTrees_size), facade=True, keepkey=False)
def __init__(self): """ TESTS:: sage: from sage.combinat.binary_tree import BinaryTrees_all sage: B = BinaryTrees_all() sage: B.cardinality() +Infinity sage: it = iter(B) sage: (it.next(), it.next(), it.next(), it.next(), it.next()) (., [., .], [., [., .]], [[., .], .], [., [., [., .]]]) sage: it.next().parent() Binary trees sage: B([]) [., .] sage: B is BinaryTrees_all() True sage: TestSuite(B).run() """ DisjointUnionEnumeratedSets.__init__( self, Family(NonNegativeIntegers(), BinaryTrees_size), facade=True, keepkey = False)