def __init__(self, *iters): """ TESTS:: sage: from sage.combinat.cartesian_product import CartesianProduct_iters sage: cp = CartesianProduct_iters([1,2],[3,4]); cp Cartesian product of [1, 2], [3, 4] sage: loads(dumps(cp)) == cp True sage: TestSuite(cp).run(skip='_test_an_element') Check that :trac:`24558` is fixed:: sage: from sage.combinat.cartesian_product import CartesianProduct_iters sage: from sage.sets.set_from_iterator import EnumeratedSetFromIterator sage: I = EnumeratedSetFromIterator(Integers) sage: CartesianProduct_iters(I, I) Cartesian product of {0, 1, -1, 2, -2, ...}, {0, 1, -1, 2, -2, ...} """ self.iters = iters self._mrange = xmrange_iter(iters) category = EnumeratedSets() try: category = category.Finite() if self.is_finite() else category.Infinite() except ValueError: # Unable to determine if it is finite or not pass def iterfunc(): # we can not use self.__iterate__ directly because # that leads to an infinite recursion in __eq__ return self.__iterate__() name = "Cartesian product of " + ", ".join(map(str, self.iters)) EnumeratedSetFromIterator.__init__(self, iterfunc, name=name, category=category, cache=False)
def __init__(self, is_infinite=False): """ Initialize ``self``. EXAMPLES:: sage: SP = SuperPartitions() sage: TestSuite(SP).run() """ cat = EnumeratedSets() if is_infinite: cat = cat.Infinite() else: cat = cat.Finite() Parent.__init__(self, category=cat)
def __init__(self, coxeter_group): r""" EXAMPLES:: sage: from sage.combinat.fully_commutative_elements import FullyCommutativeElements sage: FC = FullyCommutativeElements(CoxeterGroup(['H', 4])) sage: TestSuite(FC).run() """ self._coxeter_group = coxeter_group # Start with the category of enumerated sets and refine it to finite or # infinite enumerated sets for Coxeter groups of Cartan types. category = EnumeratedSets() coxeter_type = self._coxeter_group.coxeter_type() if not isinstance(coxeter_type, CoxeterMatrix): # This case handles all finite or affine Coxeter types (or products thereof) ctypes = [coxeter_type] if coxeter_type.is_irreducible( ) else coxeter_type.component_types() is_finite = True # this type will be FC-finite if and only if each component type is: for ctype in ctypes: family, rank = ctype.type(), ctype.rank() # Finite Coxeter groups are certainly FC-finite. # Of the affine Coxeter groups only the groups affine `F_4` and # affine `E_8` are FC-finite; they have rank 5 and rank 9 and # correspond to the groups `F_5` and `E_9` in [Ste1996]_. if not (ctype.is_finite() or (family == 'F' and rank == 5) or (family == 'E' and rank == 9)): is_finite = False break if is_finite: category = category.Finite() else: category = category.Infinite() else: # coxeter_type is a plain CoxeterMatrix, i.e. it is an indefinite # type, and we do not specify any refinement. (Note that this # includes groups of the form E_n (n>9), F_n (n>5) and H_n (n>4) # from [Ste1996]_ which are known to be FC-finite). pass Parent.__init__(self, category=category)