예제 #1
0
    def __init__(self, m, n):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: C = ColoredPermutations(4, 3)
            sage: TestSuite(C).run()
            sage: C = ColoredPermutations(2, 3)
            sage: TestSuite(C).run()
            sage: C = ColoredPermutations(1, 3)
            sage: TestSuite(C).run()
        """
        if m <= 0:
            raise ValueError("m must be a positive integer")
        self._m = ZZ(m)
        self._n = ZZ(n)
        self._C = IntegerModRing(self._m)
        self._P = Permutations(self._n)

        if self._m == 1 or self._m == 2:
            from sage.categories.finite_coxeter_groups import FiniteCoxeterGroups
            category = FiniteCoxeterGroups().Irreducible()
        else:
            from sage.categories.complex_reflection_groups import ComplexReflectionGroups
            category = ComplexReflectionGroups().Finite().Irreducible().WellGenerated()
        Parent.__init__(self, category=category)
    def __init__(self, family, facade=True, keepkey=False, category=None):
        """
        TESTS::

            sage: U = DisjointUnionEnumeratedSets({1: FiniteEnumeratedSet([1,2,3]),
            ....:                                  2: FiniteEnumeratedSet([4,5,6])})
            sage: TestSuite(U).run()

            sage: X = DisjointUnionEnumeratedSets({i: Partitions(i) for i in range(5)})
            sage: TestSuite(X).run()
        """
        self._family = family
        self._facade  = facade
        if facade:
            if family in FiniteEnumeratedSets():
                self._facade_for = tuple(family)
            else:
                # This allows the test suite to pass its tests by essentially
                #   stating that this is a facade for any parent. Technically
                #   this is wrong, but in practice, it will not have much
                #   of an effect.
                self._facade_for = True
        self._keepkey = keepkey
        if self._is_category_initialized():
            return
        if category is None:
            # try to guess if the result is infinite or not.
            if self._family in InfiniteEnumeratedSets():
                category = InfiniteEnumeratedSets()
            elif self._family.last().cardinality() == Infinity:
                category = InfiniteEnumeratedSets()
            else:
                category = FiniteEnumeratedSets()
        Parent.__init__(self, facade=facade, category=category)
예제 #3
0
    def __init__(self, n, R, var='a', category = None):
        """
        INPUT:
        
        
        -  ``n`` - the degree
        
        -  ``R`` - the base ring
        
        -  ``var`` - variable used to define field of
           definition of actual matrices in this group.
        """
        if not is_Ring(R):
            raise TypeError, "R (=%s) must be a ring"%R

        
        self._var = var
        self.__n = integer.Integer(n)
        if self.__n <= 0:
            raise ValueError, "The degree must be at least 1"
        self.__R = R

        if self.base_ring().is_finite():
            default_category = FiniteGroups()
        else:
            # Should we ask GAP whether the group is finite?
            default_category = Groups()
        if category is None:
            category = default_category
        else:
            assert category.is_subcategory(default_category), \
                "%s is not a subcategory of %s"%(category, default_category)
        Parent.__init__(self, category = category)
예제 #4
0
파일: sets_cat.py 프로젝트: TaraFife/sage
    def __init__(self):
        """
        TESTS::

            sage: P = Sets().example("inherits")
        """
        Parent.__init__(self, facade = IntegerRing(), category = Sets())
예제 #5
0
    def __init__(self, indices, prefix, category=None, names=None, **kwds):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: F = FreeMonoid(index_set=ZZ)
            sage: TestSuite(F).run()
            sage: F = FreeMonoid(index_set=tuple('abcde'))
            sage: TestSuite(F).run()

            sage: F = FreeAbelianMonoid(index_set=ZZ)
            sage: TestSuite(F).run()
            sage: F = FreeAbelianMonoid(index_set=tuple('abcde'))
            sage: TestSuite(F).run()
        """
        self._indices = indices
        category = Monoids().or_subcategory(category)
        if indices.cardinality() == 0:
            category = category.Finite()
        else:
            category = category.Infinite()
        Parent.__init__(self, names=names, category=category)

        # ignore the optional 'key' since it only affects CachedRepresentation
        kwds.pop("key", None)
        IndexedGenerators.__init__(self, indices, prefix, **kwds)
예제 #6
0
    def __init__(self, A, names=None):
        """
        Initialize ``self``.

        TESTS::

            sage: F.<x,y,z> = FreeAlgebra(QQ)
            sage: J = JordanAlgebra(F)
            sage: TestSuite(J).run()
            sage: J.category()
            Category of commutative unital algebras with basis over Rational Field
        """
        R = A.base_ring()
        C = MagmaticAlgebras(R)
        if A not in C.Associative():
            raise ValueError("A is not an associative algebra")

        self._A = A
        cat = C.Commutative()
        if A in C.Unital():
            cat = cat.Unital()
            self._no_generic_basering_coercion = True
            # Remove the preceding line once trac #16492 is fixed
            # Removing this line will also break some of the input formats,
            # see trac #16054
        if A in C.WithBasis():
            cat = cat.WithBasis()
        if A in C.FiniteDimensional():
            cat = cat.FiniteDimensional()

        Parent.__init__(self, base=R, names=names, category=cat)
예제 #7
0
파일: sets_cat.py 프로젝트: TaraFife/sage
    def __init__(self):
        """
        TESTS::

            sage: P = Sets().example("inherits")
        """
        Parent.__init__(self, category = Sets())
예제 #8
0
    def __init__(self, cartan_type, r, s):
        r"""
        Initialize the KirillovReshetikhinTableaux class.

        INPUT:

        - ``cartan_type`` -- The Cartan type
        - ``r``           -- The number of rows
        - ``s``           -- The number of columns

        EXAMPLES::

            sage: KRT = KirillovReshetikhinTableaux(['A', 4, 1], 2, 3); KRT
            Kirillov-Reshetikhin tableaux of type ['A', 4, 1] and shape (2, 3)
            sage: TestSuite(KRT).run()  # long time (4s on sage.math, 2013)
            sage: KRT = KirillovReshetikhinTableaux(['D', 4, 1], 2, 3); KRT
            Kirillov-Reshetikhin tableaux of type ['D', 4, 1] and shape (2, 3)
            sage: TestSuite(KRT).run()  # long time (53s on sage.math, 2013)
            sage: KRT = KirillovReshetikhinTableaux(['D', 4, 1], 4, 1); KRT
            Kirillov-Reshetikhin tableaux of type ['D', 4, 1] and shape (4, 1)
            sage: TestSuite(KRT).run()
        """
        self._r = r
        self._s = s
        Parent.__init__(self, category=FiniteCrystals())
        self.rename("Kirillov-Reshetikhin tableaux of type %s and shape (%d, %d)" % (cartan_type, r, s))

        self._cartan_type = cartan_type.classical()
        self.letters = CrystalOfLetters(self._cartan_type)
        
        self.module_generators = self._build_module_generators()
예제 #9
0
    def __init__(self, crystals, **options):
        """
        TESTS::

            sage: from sage.combinat.crystals.tensor_product import FullTensorProductOfCrystals
            sage: C = CrystalOfLetters(['A',2])
            sage: T = TensorProductOfCrystals(C,C)
            sage: isinstance(T, FullTensorProductOfCrystals)
            True
            sage: TestSuite(T).run()
        """
        crystals = list(crystals)
        category = Category.meet([crystal.category() for crystal in crystals])
        Parent.__init__(self, category = category)
        self.rename("Full tensor product of the crystals %s"%(crystals,))
        self.crystals = crystals
        if options.has_key('cartan_type'):
            self._cartan_type = CartanType(options['cartan_type'])
        else:
            if len(crystals) == 0:
                raise ValueError, "you need to specify the Cartan type if the tensor product list is empty"
            else:
                self._cartan_type = crystals[0].cartan_type()
        self.cartesian_product = CartesianProduct(*self.crystals)
        self.module_generators = self
예제 #10
0
    def __init__(self, cartan_type, B, biject_class):
        r"""
        Initialize all common elements for rigged configurations.

        INPUT:

        - ``cartan_type``  -- The Cartan type
        - ``B``            -- A list of dimensions `[r,s]` for rectangles of height `r` and width `s`
        - ``biject_class`` -- The class the bijection creates

        TESTS::

            sage: RC = HighestWeightRiggedConfigurations(['A', 3, 1], [[3, 2], [1, 2], [1, 1]]) # indirect doctest
            sage: RC
            Highest weight rigged configurations of type ['A', 3, 1] and factors ((3, 2), (1, 2), (1, 1))
            sage: RC = RiggedConfigurations(['A', 3, 1], [[3, 2], [1, 2], [1, 1]]) # indirect doctest
            sage: RC
            Rigged configurations of type ['A', 3, 1] and factors ((3, 2), (1, 2), (1, 1))
        """
        assert cartan_type.is_affine()
        self._affine_ct = cartan_type

        # Force to classical since we do not have e_0 and f_0 yet
        self._cartan_type = cartan_type.classical()
        self.dims = B
        self._bijection_class = biject_class
        self.rename("Rigged configurations of type %s and factors %s" % (cartan_type, B))
        Parent.__init__(self, category=FiniteCrystals())
예제 #11
0
    def __init__(self, crystals, **options):
        """
        TESTS::

            sage: from sage.combinat.crystals.tensor_product import FullTensorProductOfCrystals
            sage: C = crystals.Letters(['A',2])
            sage: T = crystals.TensorProduct(C,C)
            sage: isinstance(T, FullTensorProductOfCrystals)
            True
            sage: TestSuite(T).run()
        """
        category = Category.meet([crystal.category() for crystal in crystals])
        category = category.TensorProducts()
        if any(c in Sets().Infinite() for c in crystals):
            category = category.Infinite()
        Parent.__init__(self, category=category)
        self.crystals = crystals
        if 'cartan_type' in options:
            self._cartan_type = CartanType(options['cartan_type'])
        else:
            if not crystals:
                raise ValueError("you need to specify the Cartan type if the tensor product list is empty")
            else:
                self._cartan_type = crystals[0].cartan_type()
        self.cartesian_product = cartesian_product(self.crystals)
        self.module_generators = self
예제 #12
0
파일: spins.py 프로젝트: sageb0t/testsage
    def __init__(self, ct, element_class, case):
        """
        EXAMPLES::

            sage: E = CrystalOfSpinsMinus(['D',4])
            sage: TestSuite(E).run()
        """
        self._cartan_type = CartanType(ct)
        if case == "spins":
            self.rename("The crystal of spins for type %s"%ct)
        elif case == "plus":
            self.rename("The plus crystal of spins for type %s"%ct)
        else:
            self.rename("The minus crystal of spins for type %s"%ct)

        self.Element = element_class
#        super(GenericCrystalOfSpins, self).__init__(category = FiniteEnumeratedSets())
        Parent.__init__(self, category = ClassicalCrystals())

        if case == "minus":
            generator = [1]*(ct[1]-1)
            generator.append(-1)
        else:
            generator = [1]*ct[1]
        self.module_generators = [self(generator)]
        self._list = list(self)
#        self._digraph = ClassicalCrystal.digraph(self)
        self._digraph = super(GenericCrystalOfSpins, self).digraph()
        self._digraph_closure = self.digraph().transitive_closure()
예제 #13
0
    def __init__(self, crystals, weight, P):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: B = crystals.KirillovReshetikhin(['A',2,1], 1,1)
            sage: La = RootSystem(['A',2,1]).weight_lattice().fundamental_weights()
            sage: C = crystals.KyotoPathModel(B, La[0])
            sage: TestSuite(C).run() # long time
        """
        Parent.__init__(self, category=(HighestWeightCrystals(), InfiniteEnumeratedSets()))

        self._cartan_type = crystals[0].cartan_type()
        self._weight = weight
        if weight.parent().is_extended():
            # public for TensorProductOfCrystals
            self.crystals = tuple([C.affinization() for C in crystals])
            self._epsilon_dicts = [{b.Epsilon(): self.crystals[i](b, 0) for b in B}
                                   for i,B in enumerate(crystals)]
            self._phi_dicts = [{b.Phi(): self.crystals[i](b, 0) for b in B}
                               for i,B in enumerate(crystals)]
        else:
            # public for TensorProductOfCrystals
            self.crystals = tuple(crystals)
            self._epsilon_dicts = [{b.Epsilon(): b for b in B}
                                   for B in crystals]
            self._phi_dicts = [{b.Phi(): b for b in B}
                               for B in crystals]
        self.module_generators = (self.element_class(self, [self._phi_dicts[0][weight]]),)
예제 #14
0
    def __init__(self, base_ring, ambient_dim):
        """
        The Python constructor.

        EXAMPLES::

            sage: from sage.geometry.polyhedron.parent import Polyhedra
            sage: Polyhedra(QQ, 3)
            Polyhedra in QQ^3

        TESTS::

            sage: from sage.geometry.polyhedron.parent import Polyhedra
            sage: P = Polyhedra(QQ, 3)
            sage: TestSuite(P).run(skip='_test_pickling')
        """
        self._ambient_dim = ambient_dim
        from sage.categories.polyhedra import PolyhedralSets

        Parent.__init__(self, base=base_ring, category=PolyhedralSets(base_ring))
        self._Inequality_pool = []
        self._Equation_pool = []
        self._Vertex_pool = []
        self._Ray_pool = []
        self._Line_pool = []
예제 #15
0
파일: set.py 프로젝트: DrXyzzy/sage
    def __init__(self, X):
        """
        Create a Set_object

        This function is called by the Set function; users
        shouldn't call this directly.

        EXAMPLES::

            sage: type(Set(QQ))
            <class 'sage.sets.set.Set_object_with_category'>

        TESTS::

            sage: _a, _b = get_coercion_model().canonical_coercion(Set([0]), 0)
            Traceback (most recent call last):
            ...
            TypeError: no common canonical parent for objects with parents:
            '<class 'sage.sets.set.Set_object_enumerated_with_category'>'
            and 'Integer Ring'
        """
        from sage.rings.integer import is_Integer
        if isinstance(X, (int,long)) or is_Integer(X):
            # The coercion model will try to call Set_object(0)
            raise ValueError('underlying object cannot be an integer')
        Parent.__init__(self, category=Sets())
        self.__object = X
예제 #16
0
    def __init__(self, wt, WLR):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: La = RootSystem(['A', 2]).weight_lattice().fundamental_weights()
            sage: RC = crystals.RiggedConfigurations(La[1] + La[2])
            sage: TestSuite(RC).run()

            sage: La = RootSystem(['A', 2, 1]).weight_lattice().fundamental_weights()
            sage: RC = crystals.RiggedConfigurations(La[0])
            sage: TestSuite(RC).run() # long time
        """
        self._cartan_type = WLR.cartan_type()
        self._wt = wt
        self._rc_index = self._cartan_type.index_set()
        # We store the cartan matrix for the vacancy number calculations for speed
        self._cartan_matrix = self._cartan_type.cartan_matrix()
        if self._cartan_type.is_finite():
            category = ClassicalCrystals()
        else:
            category = (RegularCrystals(), HighestWeightCrystals(), InfiniteEnumeratedSets())
        Parent.__init__(self, category=category)
        n = self._cartan_type.rank() #== len(self._cartan_type.index_set())
        self.module_generators = (self.element_class( self, partition_list=[[] for i in range(n)] ),)
예제 #17
0
    def __init__(self, x, degree=None):
        """
        EXAMPLES::

            sage: R.<x> = PolynomialRing(QQ)
            sage: f = x^4 - 17*x^3 - 2*x + 1
            sage: G = f.galois_group(pari_group=True); G
            PARI group [24, -1, 5, "S4"] of degree 4
            sage: G.category()
            Category of finite groups

        Caveat: fix those tests and/or document precisely that this is
        an abstract group without explicit elements::

            sage: TestSuite(G).run(skip = ["_test_an_element",
            ....:                          "_test_associativity",
            ....:                          "_test_elements",
            ....:                          "_test_elements_eq_reflexive",
            ....:                          "_test_elements_eq_symmetric",
            ....:                          "_test_elements_eq_transitive",
            ....:                          "_test_elements_neq",
            ....:                          "_test_enumerated_set_contains",
            ....:                          "_test_enumerated_set_iter_cardinality",
            ....:                          "_test_enumerated_set_iter_list",
            ....:                          "_test_inverse",
            ....:                          "_test_one",
            ....:                          "_test_prod",
            ....:                          "_test_some_elements"])
        """
        if not isinstance(x, pari_gen):
            raise TypeError("x (=%s) must be a PARI gen" % x)
        self.__x = x
        self.__degree = degree
        from sage.categories.finite_groups import FiniteGroups
        Parent.__init__(self, category=FiniteGroups())
예제 #18
0
파일: subset.py 프로젝트: Etn40ff/sage
    def __init__(self, s):
        """
        TESTS::

            sage: s = Subsets(Set([1]))
            sage: e = s.first()
            sage: isinstance(e, s.element_class)
            True

        In the following "_test_elements" is temporarily disabled
        until :class:`sage.sets.set.Set_object_enumerated` objects
        pass the category tests::

            sage: S = Subsets([1,2,3])
            sage: TestSuite(S).run(skip=["_test_elements"])

            sage: S = sage.sets.set.Set_object_enumerated([1,2])
            sage: TestSuite(S).run()         # todo: not implemented
        """
        Parent.__init__(self, category=EnumeratedSets().Finite())
        if s not in EnumeratedSets():
            from sage.misc.misc import uniq
            from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
            s = list(s)
            us = uniq(s)
            if len(us) == len(s):
                s = FiniteEnumeratedSet(s)
            else:
                s = FiniteEnumeratedSet(us)
        self._s  = s
예제 #19
0
    def __init__(self, base, prec, names, element_class, category=None):
        """
        Initializes self.

        EXAMPLES::

            sage: R = Zp(5) #indirect doctest
            sage: R.precision_cap()
            20

        In :trac:`14084`, the category framework has been implemented for p-adic rings::

            sage: TestSuite(R).run()
            sage: K = Qp(7)
            sage: TestSuite(K).run()

        TESTS::

            sage: R = Zp(5, 5, 'fixed-mod')
            sage: R._repr_option('element_is_atomic')
            False
        """
        self._prec = prec
        self.Element = element_class
        default_category = getattr(self, '_default_category', None)
        if self.is_field():
            category = CompleteDiscreteValuationFields()
        else:
            category = CompleteDiscreteValuationRings()
        if default_category is not None:
            category = check_default_category(default_category, category)
        Parent.__init__(self, base, names=(names,), normalize=False, category=category, element_constructor=element_class)
예제 #20
0
파일: semigroups.py 프로젝트: biasse/sage
    def __init__(self, category = None):
        r"""
        This quotient of the left zero semigroup of integers obtained by
        setting `x=42` for any `x\geq 42`.

        EXAMPLES::

            sage: S = Semigroups().Subquotients().example(); S
            An example of a (sub)quotient semigroup: a quotient of the left zero semigroup
            sage: S.ambient()
            An example of a semigroup: the left zero semigroup
            sage: S(100)
            42
            sage: S(100) == S(42)
            True
            sage: S(1)*S(2) == S(1)
            True

        TESTS::

            sage: TestSuite(S).run()
        """
        if category is None:
            category = Semigroups().Quotients()
        Parent.__init__(self, category = category)
예제 #21
0
 def __init__(self, G, V, trivial_action = False):
     self._group = G
     self._coeffmodule = V
     self._trivial_action = trivial_action
     self._gen_pows = []
     self._gen_pows_neg = []
     if trivial_action:
         self._acting_matrix = lambda x, y: matrix(V.base_ring(),V.dimension(),V.dimension(),1)
         gens_local = [ (None, None) for g in G.gens() ]
     else:
         def acting_matrix(x,y):
             try:
                 return V.acting_matrix(x,y)
             except:
                 return V.acting_matrix(G.embed(x.quaternion_rep,V.base_ring().precision_cap()), y)
         self._acting_matrix = acting_matrix
         gens_local = [ (g, g**-1) for g in G.gens() ]
     onemat = G(1)
     try:
         dim = V.dimension()
     except AttributeError:
         dim = len(V.basis())
     one = Matrix(V.base_ring(),dim,dim,1)
     for g, ginv in gens_local:
         A = self._acting_matrix(g, dim)
         self._gen_pows.append([one, A])
         Ainv = self._acting_matrix(ginv, dim)
         self._gen_pows_neg.append([one, Ainv])
     Parent.__init__(self)
     return
예제 #22
0
파일: family.py 프로젝트: DrXyzzy/sage
    def __init__(self, set, function, name=None):
        """
        TESTS::

            sage: from sage.sets.family import LazyFamily
            sage: f = LazyFamily([3,4,7], lambda i: 2*i); f
            Lazy family (<lambda>(i))_{i in [3, 4, 7]}
            sage: TestSuite(f).run()   # __contains__ is not implemented
            Failure ...
            The following tests failed: _test_an_element, _test_enumerated_set_contains, _test_some_elements

        Check for bug #5538::

            sage: l = [3,4,7]
            sage: f = LazyFamily(l, lambda i: 2*i);
            sage: l[1] = 18
            sage: f
            Lazy family (<lambda>(i))_{i in [3, 4, 7]}
        """
        from sage.combinat.combinat import CombinatorialClass # workaround #12482

        if set in FiniteEnumeratedSets():
            category = FiniteEnumeratedSets()
        elif set in InfiniteEnumeratedSets():
            category = InfiniteEnumeratedSets()
        elif isinstance(set, (list, tuple, CombinatorialClass)):
            category = FiniteEnumeratedSets()
        else:
            category = EnumeratedSets()

        Parent.__init__(self, category = category)
        from copy import copy
        self.set = copy(set)
        self.function = function
        self.function_name = name
예제 #23
0
    def __init__(self, poset, facade):
        """
        TESTS::

            sage: from sage.combinat.posets.linear_extensions import LinearExtensionsOfPoset
            sage: P = Poset(([1,2,3],[[1,2],[1,3]]))
            sage: L = P.linear_extensions()
            sage: L is LinearExtensionsOfPoset(P)
            True
            sage: L._poset is P
            True
            sage: L._linear_extensions_of_hasse_diagram
            Linear extensions of Hasse diagram of a poset containing 3 elements
            sage: TestSuite(L).run()

            sage: P = Poset((divisors(15), attrcall("divides")))
            sage: L = P.linear_extensions()
            sage: TestSuite(L).run()

            sage: P = Poset((divisors(15), attrcall("divides")), facade=True)
            sage: L = P.linear_extensions()
            sage: TestSuite(L).run()

            sage: L = P.linear_extensions(facade = True)
            sage: TestSuite(L).run(skip="_test_an_element")
        """
        self._poset = poset
        self._linear_extensions_of_hasse_diagram = sage.graphs.linearextensions.LinearExtensions(poset._hasse_diagram)
        self._is_facade = facade
        if facade:
            facade = (list,)
        Parent.__init__(self, category = FiniteEnumeratedSets(), facade=facade)
예제 #24
0
파일: affine.py 프로젝트: biasse/sage
    def __init__(self, cartan_type, classical_crystal, category = None):
        """
        Input is an affine Cartan type 'cartan_type', a classical crystal 'classical_crystal', and automorphism and its
        inverse 'automorphism' and 'inverse_automorphism', and the Dynkin node 'dynkin_node'

        EXAMPLES::

            sage: n = 1
            sage: C = CrystalOfTableaux(['A',n],shape=[1])
            sage: pr = attrcall("promotion")
            sage: pr_inverse = attrcall("promotion_inverse")
            sage: A = AffineCrystalFromClassicalAndPromotion(['A',n,1],C,pr,pr_inverse,1) # indirect doctest
            sage: A.list()
            [[[1]], [[2]]]
            sage: A.cartan_type()
            ['A', 1, 1]
            sage: A.index_set()
            (0, 1)

        Note: AffineCrystalFromClassical is an abstract class, so we
        can't test it directly.

        TESTS::

            sage: TestSuite(A).run()
        """
        if category is None:
            category = (RegularCrystals(), FiniteCrystals())
        self._cartan_type = cartan_type
        Parent.__init__(self, category = category)
        self.classical_crystal = classical_crystal;
        self.module_generators = map( self.retract, self.classical_crystal.module_generators )
        self.element_class._latex_ = lambda x: x.lift()._latex_()
예제 #25
0
파일: dual.py 프로젝트: sagemath/sage
    def __init__(self, R):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: NCSymD1 = SymmetricFunctionsNonCommutingVariablesDual(FiniteField(23))
            sage: NCSymD2 = SymmetricFunctionsNonCommutingVariablesDual(Integers(23))
            sage: TestSuite(SymmetricFunctionsNonCommutingVariables(QQ).dual()).run()
        """
        # change the line below to assert(R in Rings()) once MRO issues from #15536, #15475 are resolved
        assert(R in Fields() or R in Rings()) # side effect of this statement assures MRO exists for R
        self._base = R # Won't be needed once CategoryObject won't override base_ring
        category = GradedHopfAlgebras(R)  # TODO: .Commutative()
        Parent.__init__(self, category=category.WithRealizations())

        # Bases
        w = self.w()

        # Embedding of Sym in the homogeneous bases into DNCSym in the w basis
        Sym = SymmetricFunctions(self.base_ring())
        Sym_h_to_w = Sym.h().module_morphism(w.sum_of_partitions,
                                             triangular='lower',
                                             inverse_on_support=w._set_par_to_par,
                                             codomain=w, category=category)
        Sym_h_to_w.register_as_coercion()
        self.to_symmetric_function = Sym_h_to_w.section()
예제 #26
0
    def __init__(self, space, name, short_name, bounded, conformal,
                 dimension, isometry_group, isometry_group_is_projective):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: UHP = HyperbolicPlane().UHP()
            sage: TestSuite(UHP).run()
            sage: PD = HyperbolicPlane().PD()
            sage: TestSuite(PD).run()
            sage: KM = HyperbolicPlane().KM()
            sage: TestSuite(KM).run()
            sage: HM = HyperbolicPlane().HM()
            sage: TestSuite(HM).run()
        """
        self._name = name
        self._short_name = short_name
        self._bounded = bounded
        self._conformal = conformal
        self._dimension = dimension
        self._isometry_group = isometry_group
        self._isometry_group_is_projective = isometry_group_is_projective
        from sage.geometry.hyperbolic_space.hyperbolic_interface import HyperbolicModels
        Parent.__init__(self, category=HyperbolicModels(space))
예제 #27
0
    def __init__(self, f, args=None, kwds=None, name=None, category=None, cache=False):
        """
        TESTS::

            sage: from sage.sets.set_from_iterator import EnumeratedSetFromIterator
            sage: S = EnumeratedSetFromIterator(xsrange, (1,200,-1), category=FiniteEnumeratedSets())
            sage: TestSuite(S).run()
        """
        if category is not None:
            Parent.__init__(self, facade = True, category = category)
        else:
            Parent.__init__(self, facade = True, category = EnumeratedSets())


        if name is not None:
            self.rename(name)

        self._func = f

        if args is not None:
            self._args = args
        if kwds is not None:
            self._kwds = kwds

        if cache:
            self._cache = lazy_list(iter(self._func(
                                         *getattr(self, '_args', ()),
                                        **getattr(self, '_kwds', {}))))
예제 #28
0
 def __init__(self, base, parent_approximation, models=None, exact=Infinity,
              category=None, element_constructor=None, gens=None, names=None, normalize=True, facade=None):
     Parent.__init__(self,base,category=category,element_constructor=element_constructor,
                     gens=gens, names=names, normalize=normalize, facade=facade)
     self._approximation = parent_approximation
     self._precision = ParentBigOh(self)
     if models is None:
         dimension = self.dimension()
         if dimension == 1:
             self._precision.add_model(ValuationBigOh)
         else:
             if self.dimension() < Infinity:
                 self._precision.add_model(FlatBigOh)
             self._precision.add_model(JaggedBigOh)
             try:
                 if self.indices_basis() is None:
                     self._precision.add_model(FlatIntervalBigOh)
                     self._precision.add_modelconversion(FlatIntervalBigOh,JaggedBigOh)
             except NotImplementedError:
                 pass
             self._precision.add_modelconversion(FlatBigOh,JaggedBigOh,safemode=True)
             self._precision.add_modelconversion(FlatBigOh,FlatIntervalBigOh,safemode=True)
     else:
         for model in models.vertices():
             self._precision.add_model(model)
         for (mfrom,mto,map) in models.edges():
             self._precision.add_modelconversion(mfrom,mto,map)
     try:
         self._exact_precision = self._precision(exact)
     except PrecisionError:
         self._exact_precision = ExactBigOh(self._precision)
예제 #29
0
    def __init__(self, begin, end, step=Integer(1), middle_point=Integer(1)):
        r"""
        TESTS::

            sage: from sage.sets.integer_range import IntegerRangeFromMiddle
            sage: I = IntegerRangeFromMiddle(-100,100,10,0)
            sage: I.category()
            Category of facade finite enumerated sets
            sage: TestSuite(I).run()
            sage: I = IntegerRangeFromMiddle(Infinity,-Infinity,-37,0)
            sage: I.category()
            Category of facade infinite enumerated sets
            sage: TestSuite(I).run()

            sage: IntegerRange(0, 5, 1, -3)
            Traceback (most recent call last):
            ...
            ValueError: middle_point is not in the interval
        """
        self._begin = begin
        self._end = end
        self._step = step
        self._middle_point = middle_point
        if not middle_point in self:
            raise ValueError("middle_point is not in the interval")

        if (begin != Infinity and begin != -Infinity) and \
             (end != Infinity and end != -Infinity):
            Parent.__init__(self, facade = IntegerRing(), category = FiniteEnumeratedSets())
        else:
            Parent.__init__(self, facade = IntegerRing(), category = InfiniteEnumeratedSets())
예제 #30
0
    def __init__(self, sets, category, flatten=False):
        r"""
        INPUT:

         - ``sets`` -- a tuple of parents
         - ``category`` -- a subcategory of ``Sets().CartesianProducts()``
         - ``flatten`` -- a boolean (default: ``False``)

        ``flatten`` is current ignored, and reserved for future use.

        No other keyword arguments (``kwargs``) are accepted.

        TESTS::

            sage: from sage.sets.cartesian_product import CartesianProduct
            sage: C = CartesianProduct((QQ, ZZ, ZZ), category = Sets().CartesianProducts())
            sage: C
            The Cartesian product of (Rational Field, Integer Ring, Integer Ring)
            sage: C.an_element()
            (1/2, 1, 1)
            sage: TestSuite(C).run()
            sage: cartesian_product([ZZ, ZZ], blub=None)
            Traceback (most recent call last):
            ...
            TypeError: __init__() got an unexpected keyword argument 'blub'
        """
        self._sets = tuple(sets)
        Parent.__init__(self, category=category)
예제 #31
0
    def __call__(self, *args, **keywords):
        r"""
        TESTS::

            sage: from sage.structure.set_factories_example import XYPairs
            sage: S = XYPairs()
            sage: el = S((2,3)); el
            (2, 3)
            sage: S(el) is el
            True

            sage: XYPairs(x=3)((2,3))
            Traceback (most recent call last):
            ...
            ValueError: Wrong first coordinate

            sage: XYPairs(x=3)(el)
            Traceback (most recent call last):
            ...
            ValueError: Wrong first coordinate
        """
        # Ensure idempotence of element construction
        if (len(args) == 1 and isinstance(args[0], self.element_class)
                and args[0].parent() == self._parent_for):
            check = keywords.get("check", True)
            if check:
                self.check_element(args[0], check)
            return args[0]
        else:
            return Parent.__call__(self, *args, **keywords)
예제 #32
0
    def __init__(self, e):
        """
        TESTS::

            sage: LW21 = LyndonWords([2,1]); LW21
            Lyndon words with evaluation [2, 1]
            sage: LW21 == loads(dumps(LW21))
            True
        """
        self._e = e
        self._words = FiniteWords(len(e))

        from sage.categories.enumerated_sets import EnumeratedSets
        Parent.__init__(self,
                        category=EnumeratedSets().Finite(),
                        facade=(self._words, ))
예제 #33
0
    def __call__(self, x=None, im=None):
        """
        Create a complex number.

        EXAMPLES::

            sage: CC(2) # indirect doctest
            2.00000000000000
            sage: CC(CC.0)
            1.00000000000000*I
            sage: CC('1+I')
            1.00000000000000 + 1.00000000000000*I
            sage: CC(2,3)
            2.00000000000000 + 3.00000000000000*I
            sage: CC(QQ[I].gen())
            1.00000000000000*I
            sage: CC.gen() + QQ[I].gen()
            Traceback (most recent call last):
            ...
            TypeError: unsupported operand parent(s) for '+': 'Complex Field with 53 bits of precision' and 'Number Field in I with defining polynomial x^2 + 1'

        In the absence of arguments we return zero::

            sage: a = CC(); a
            0.000000000000000
            sage: a.parent()
            Complex Field with 53 bits of precision
        """
        if x is None:
            return self.zero()
        # we leave this here to handle the imaginary parameter
        if im is not None:
            x = x, im
        return Parent.__call__(self, x)
예제 #34
0
    def __init__(self, W):
        r"""
        EXAMPLES::

            sage: WeylGroup(['B',5]).pieri_factors()
            Pieri factors for Weyl Group of type ['B', 5] (as a matrix group acting on the ambient space)

        TESTS::

            sage: PF = WeylGroup(['B',3]).pieri_factors()
            sage: PF.__class__
            <class 'sage.combinat.root_system.pieri_factors.PieriFactors_type_B_with_category'>
            sage: TestSuite(PF).run()
        """
        Parent.__init__(self, category=FiniteEnumeratedSets())
        self.W = W
예제 #35
0
    def __init__(self, s):
        """
        Constructs the combinatorial class of the sub multisets of s.

        EXAMPLES::

            sage: S = Subsets([1,2,2,3], submultiset=True)
            sage: Subsets([1,2,3,3], submultiset=True).cardinality()
            12
            sage: TestSuite(S).run()
        """
        Parent.__init__(self, category=FiniteEnumeratedSets())

        self._d = s
        if not isinstance(s, dict):
            self._d = list_to_dict(s)
예제 #36
0
    def __init__(self, x):
        """
        Initalize ``self``.

        EXAMPLES::

            sage: D = Derangements(4)
            sage: TestSuite(D).run()
            sage: D = Derangements('abcd')
            sage: TestSuite(D).run()
            sage: D = Derangements([2, 2, 1, 1])
            sage: TestSuite(D).run()
        """
        Parent.__init__(self, category=FiniteEnumeratedSets())
        self._set = x
        self.__multi = len(set(x)) < len(x)
예제 #37
0
파일: value_group.py 프로젝트: yabirgb/sage
    def __init__(self, generator):
        r"""
        TESTS::

            sage: from sage.rings.valuation.value_group import DiscreteValueGroup
            sage: isinstance(DiscreteValueGroup(0), DiscreteValueGroup)
            True

        """
        from sage.categories.modules import Modules
        self._generator = generator

        # We can not set the facade to DiscreteValuationCodomain since there
        # are some issues with iterated facades currently
        UniqueRepresentation.__init__(self)
        Parent.__init__(self, facade=QQ, category=Modules(ZZ))
예제 #38
0
    def __init__(self, field):
        """
        Initialize.

        TESTS::

            sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
            sage: F.<y> = K.extension(Y^2 - x^3 - 1)
            sage: G = F.divisor_group()
            sage: TestSuite(G).run()
        """
        Parent.__init__(self,
                        base=IntegerRing(),
                        category=CommutativeAdditiveGroups())

        self._field = field  # function field
예제 #39
0
    def __init__(self, begin, step=Integer(1)):
        r"""
        TESTS::

            sage: I = IntegerRange(-57,Infinity,8)
            sage: I.category()
            Category of facade infinite enumerated sets
            sage: TestSuite(I).run()
        """
        if not isinstance(begin, Integer):
            raise TypeError("begin should be Integer, not %r" % type(begin))
        self._begin = begin
        self._step = step
        Parent.__init__(self,
                        facade=IntegerRing(),
                        category=InfiniteEnumeratedSets())
예제 #40
0
파일: value_group.py 프로젝트: yjjcc/sage
    def __init__(self):
        r"""
        TESTS::

            sage: from sage.rings.valuation.value_group import DiscreteValuationCodomain
            sage: isinstance(QQ.valuation(2).codomain(), DiscreteValuationCodomain)
            True

        """
        from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
        from sage.categories.additive_monoids import AdditiveMonoids
        UniqueRepresentation.__init__(self)
        Parent.__init__(self,
                        facade=(QQ, FiniteEnumeratedSet([infinity,
                                                         -infinity])),
                        category=AdditiveMonoids())
예제 #41
0
    def __call__(self, *args, **kwds):
        r"""
        Construct an element of ``self`` from the input.

        EXAMPLES::

            sage: M = Manifold(2, 'M', structure='topological')
            sage: X.<x,y> = M.chart()
            sage: N = Manifold(3, 'N', structure='topological')
            sage: Y.<u,v,w> = N.chart()
            sage: H = Hom(M,N)
            sage: f = H.__call__({(X, Y): [x+y, x-y, x*y]}, name='f') ; f
            Continuous map f from the 2-dimensional topological manifold M to
             the 3-dimensional topological manifold N
            sage: f.display()
            f: M --> N
               (x, y) |--> (u, v, w) = (x + y, x - y, x*y)

        There is also the following shortcut for :meth:`one`::

            sage: M = Manifold(2, 'M', structure='topological')
            sage: H = Hom(M, M)
            sage: H(1)
            Identity map Id_M of the 2-dimensional topological manifold M
        """
        if len(args) == 1:
            if self.domain() == self.codomain() and args[0] == 1:
                return self.one()
            if isinstance(args[0], ContinuousMap):
                return Homset.__call__(self, args[0])
        return Parent.__call__(self, *args, **kwds)
예제 #42
0
    def __init__(self, crystals, generators, cartan_type):
        """
        EXAMPLES::

            sage: C = CrystalOfLetters(['A',2])
            sage: T = TensorProductOfCrystals(C,C,C,generators=[[C(2),C(1),C(1)]])
            sage: TestSuite(T).run()
        """
        assert isinstance(crystals, tuple)
        assert isinstance(generators, tuple)
        category = Category.meet([crystal.category() for crystal in crystals])
        Parent.__init__(self, category = category)
        self.rename("The tensor product of the crystals %s"%(crystals,))
        self.crystals = crystals
        self._cartan_type = cartan_type
        self.module_generators = [ self(*x) for x in generators ]
예제 #43
0
    def __init__(self, category=None):
        """
        TESTS::

            sage: NN = NonNegativeIntegers()
            sage: NN
            Non negative integers
            sage: NN.category()
            Category of facade infinite enumerated sets
            sage: TestSuite(NN).run()
        """
        from sage.rings.integer_ring import ZZ
        Parent.__init__(
            self,
            facade=ZZ,
            category=InfiniteEnumeratedSets().or_subcategory(category))
예제 #44
0
    def __init__(self, R, form, names=None):
        """
        Initialize ``self``.

        TESTS::

            sage: m = matrix([[-2,3],[3,4]])
            sage: J = JordanAlgebra(m)
            sage: TestSuite(J).run()
        """
        self._form = form
        self._M = FreeModule(R, form.ncols())
        cat = MagmaticAlgebras(
            R).Commutative().Unital().FiniteDimensional().WithBasis()
        self._no_generic_basering_coercion = True  # Remove once 16492 is fixed
        Parent.__init__(self, base=R, names=names, category=cat)
예제 #45
0
    def __init__(self, n, names):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: F = FreeAbelianMonoid(6,'b')
            sage: TestSuite(F).run()
        """
        if not isinstance(n, (int, Integer)):
            raise TypeError("n (=%s) must be an integer" % n)
        if n < 0:
            raise ValueError("n (=%s) must be nonnegative" % n)
        self.__ngens = int(n)
        assert names is not None
        Parent.__init__(self, names=names, category=Monoids().Commutative())
예제 #46
0
    def __init__(self, matrices, matrix_space=None, category=None):
        if matrix_space is None:
            from sage.matrix.matrix_space import MatrixSpace
            ring = Sequence(matrices).universe().base_ring()
            matrix_space = MatrixSpace(ring, 2)

        self._generators = list(map(matrix_space, matrices))
        for m in self._generators:
            m.set_immutable()
        self._matrix_space = matrix_space

        if category is None:
            from sage.categories.groups import Groups
            category = Groups()

        Parent.__init__(self, category=category, facade=matrix_space)
예제 #47
0
    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), [])
예제 #48
0
    def __init__(self, category = None):
        r"""
        An incompletely implemented subquotient semigroup, for testing purposes

        EXAMPLES::

            sage: S = sage.categories.examples.semigroups.IncompleteSubquotientSemigroup()
            sage: S
            A subquotient of An example of a semigroup: the left zero semigroup

        TESTS::

            sage: S._test_not_implemented_methods()
            Traceback (most recent call last):
              ...
            AssertionError: Not implemented method: lift

            sage: TestSuite(S).run(verbose = True)
            running ._test_an_element() . . . pass
            running ._test_associativity() . . . fail
            Traceback (most recent call last):
              ...
            NotImplementedError: <abstract method retract at ...>
            ------------------------------------------------------------
            running ._test_category() . . . pass
            running ._test_elements() . . .
              Running the test suite of self.an_element()
              running ._test_category() . . . pass
              running ._test_eq() . . . pass
              running ._test_not_implemented_methods() . . . pass
              running ._test_pickling() . . . pass
              pass
            running ._test_elements_eq_reflexive() . . . pass
            running ._test_elements_eq_symmetric() . . . pass
            running ._test_elements_eq_transitive() . . . pass
            running ._test_elements_neq() . . . pass
            running ._test_eq() . . . pass
            running ._test_not_implemented_methods() . . . fail
            Traceback (most recent call last):
              ...
            AssertionError: Not implemented method: lift
            ------------------------------------------------------------
            running ._test_pickling() . . . pass
            running ._test_some_elements() . . . pass
            The following tests failed: _test_associativity, _test_not_implemented_methods
        """
        Parent.__init__(self, category=Semigroups().Subquotients().or_subcategory(category))
예제 #49
0
    def __init__(self, X=None, category=None):
        """
        Construct a scheme.

        TESTS:

        The full test suite works since :trac:`7946`::

            sage: R.<x, y> = QQ[]
            sage: I = (x^2 - y^2)*R
            sage: RmodI = R.quotient(I)
            sage: X = Spec(RmodI)
            sage: TestSuite(X).run()

        """
        from sage.schemes.generic.morphism import is_SchemeMorphism
        from sage.categories.map import Map
        from sage.categories.all import Rings

        if X is None:
            self._base_ring = ZZ
        elif is_Scheme(X):
            self._base_scheme = X
        elif is_SchemeMorphism(X):
            self._base_morphism = X
        elif isinstance(X, CommutativeRing):
            self._base_ring = X
        elif isinstance(X, Map) and X.category_for().is_subcategory(Rings()):
            # X is a morphism of Rings
            self._base_ring = X.codomain()
        else:
            raise ValueError('The base must be define by a scheme, '
                             'scheme morphism, or commutative ring.')

        from sage.categories.schemes import Schemes
        if X is None:
            default_category = Schemes()
        else:
            default_category = Schemes(self.base_scheme())
        if category is None:
            category = default_category
        else:
            assert category.is_subcategory(default_category), \
                "%s is not a subcategory of %s"%(category, default_category)

        Parent.__init__(self, self.base_ring(), category=category)
예제 #50
0
    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)
예제 #51
0
    def __init__(self, X, Y, category=None, base=None, check=True):
        r"""
        TESTS::

            sage: X = ZZ['x']; X.rename("X")
            sage: Y = ZZ['y']; Y.rename("Y")
            sage: class MyHomset(Homset):
            ...       def my_function(self, x):
            ...           return Y(x[0])
            ...       def _an_element_(self):
            ...           return sage.categories.morphism.SetMorphism(self, self.my_function)
            ...
            sage: import __main__; __main__.MyHomset = MyHomset # fakes MyHomset being defined in a Python module
            sage: H = MyHomset(X, Y, category=Monoids(), base = ZZ)
            sage: H
            Set of Morphisms from X to Y in Category of monoids
            sage: TestSuite(H).run()

            sage: H = MyHomset(X, Y, category=1, base = ZZ)
            Traceback (most recent call last):
            ...
            TypeError: category (=1) must be a category

            sage: H
            Set of Morphisms from X to Y in Category of monoids
            sage: TestSuite(H).run()
            sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
            Traceback (most recent call last):
            ...
            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'hom_category'
        """

        self._domain = X
        self._codomain = Y
        if category is None:
            category = X.category()
        self.__category = category
        if check:
            if not isinstance(category, Category):
                raise TypeError, "category (=%s) must be a category" % category
            #if not X in category:
            #    raise TypeError, "X (=%s) must be in category (=%s)"%(X, category)
            #if not Y in category:
            #    raise TypeError, "Y (=%s) must be in category (=%s)"%(Y, category)

        Parent.__init__(self, base=base, category=category.hom_category())
    def __init__(self, n, ring=None, cache_matrices=True):
        r"""
        Irreducible representations of the symmetric group.

        See the documentation for :func:`SymmetricGroupRepresentations`
        for more information.

        EXAMPLES::

            sage: snorm = SymmetricGroupRepresentations(3, "seminormal")
            sage: snorm == loads(dumps(snorm))
            True
        """
        self._n = n
        self._ring = ring if ring is not None else self._default_ring
        self._cache_matrices = cache_matrices
        Parent.__init__(self, category=FiniteEnumeratedSets())
예제 #53
0
파일: scheme.py 프로젝트: shrutig/sage
    def __init__(self, X=None, category=None):
        """
        Construct a scheme.

        TESTS::

            sage: R.<x, y> = QQ[]
            sage: I = (x^2 - y^2)*R
            sage: RmodI = R.quotient(I)
            sage: X = Spec(RmodI)
            sage: TestSuite(X).run(skip = ["_test_an_element", "_test_elements",
            ...                            "_test_some_elements", "_test_category"]) # See #7946
        """
        from sage.schemes.generic.spec import is_Spec
        from sage.schemes.generic.morphism import is_SchemeMorphism

        if X is None:
            try:
                from sage.schemes.generic.spec import SpecZ
                self._base_scheme = SpecZ
            except ImportError:  # we are currently constructing SpecZ
                self._base_ring = ZZ
        elif is_Scheme(X):
            self._base_scheme = X
        elif is_SchemeMorphism(X):
            self._base_morphism = X
        elif is_CommutativeRing(X):
            self._base_ring = X
        elif is_RingHomomorphism(X):
            self._base_ring = X.codomain()
        else:
            raise ValueError('The base must be define by a scheme, '
                             'scheme morphism, or commutative ring.')

        from sage.categories.schemes import Schemes
        if not X:
            default_category = Schemes()
        else:
            default_category = Schemes(self.base_scheme())
        if category is None:
            category = default_category
        else:
            assert category.is_subcategory(default_category), \
                "%s is not a subcategory of %s"%(category, default_category)

        Parent.__init__(self, self.base_ring(), category=category)
예제 #54
0
    def __init__(self, R):
        """
        Initialize ``self``.

        TESTS::

            sage: A = algebras.FQSym(QQ); A
            Free Quasi-symmetric functions over Rational Field
            sage: TestSuite(A).run()  # long time (3s)

            sage: F = algebras.FQSym(QQ)
            sage: TestSuite(F).run() # long time (3s)
        """
        self._category = HopfAlgebras(R).Graded().Connected()
        Parent.__init__(self,
                        base=R,
                        category=self._category.WithRealizations())
예제 #55
0
    def __init__(self, X, phi, inverse):
        """
        Initialize ``self``.

        TESTS:

        Note that pickling only works when the input functions
        can be pickled::

            sage: D = crystals.Tableaux(['A',3], shapes=PartitionsInBox(4,1))
            sage: G = GelfandTsetlinPatterns(4, 1)
            sage: def phi(x): return D(x.to_tableau())
            sage: def phi_inv(x): return G(x.to_tableau())
            sage: import __main__
            sage: __main__.phi = phi
            sage: __main__.phi_inv = phi_inv
            sage: I = crystals.Induced(D, phi_inv, phi, from_crystal=True)
            sage: TestSuite(I).run()
        """
        self._crystal = X
        self._phi = phi

        if inverse is None:
            try:
                inverse = ~self._phi
            except (TypeError, ValueError):
                try:
                    inverse = self._phi.section()
                except AttributeError:
                    if X.cardinality() == float('inf'):
                        raise ValueError(
                            "the inverse map must be defined for infinite sets"
                        )
                    self._preimage = {}
                    for x in X:
                        y = phi(x)
                        if y in self._preimage:
                            raise ValueError("the map is not injective")
                        self._preimage[y] = x
                    inverse = self._preimage.__getitem__
        self._inverse = inverse

        self._cartan_type = X.cartan_type()
        Parent.__init__(self, category=X.category())
        self.module_generators = tuple(
            self.element_class(self, phi(mg)) for mg in X.module_generators)
예제 #56
0
    def __init__(self, R):
        """
        EXAMPLES::

            sage: Sym = SymmetricFunctions(QQ)

        TESTS:

        There are a lot of missing features for this abstract parent. But some tests do pass::

            sage: TestSuite(Sym).run()
            Failure ...
            The following tests failed: _test_additive_associativity, _test_an_element, _test_associativity, _test_distributivity, _test_elements, _test_elements_eq, _test_not_implemented_methods, _test_one, _test_prod, _test_some_elements, _test_zero
        """
        assert(R in Rings())
        self._base = R # Won't be needed when CategoryObject won't override anymore base_ring
        Parent.__init__(self, category = GradedHopfAlgebrasWithBasis(R).abstract_category())
예제 #57
0
파일: infinity.py 프로젝트: yarv/sage
    def __init__(self):
        """
        Initialize ``self``.

        TESTS::

            sage: sage.rings.infinity.InfinityRing_class() is sage.rings.infinity.InfinityRing_class() is InfinityRing
            True

        Comparison tests::

            sage: InfinityRing == InfinityRing
            True
            sage: InfinityRing == UnsignedInfinityRing
            False
        """
        Parent.__init__(self, self, names=('oo', ), normalize=False)
예제 #58
0
    def __init__(self, n=5):
        r"""
        INPUT:
         - ``n`` - an integer with `n>=2`

        Construct the n-th DihedralGroup of order 2*n

        EXAMPLES::

            sage: from sage.categories.examples.finite_coxeter_groups import DihedralGroup
            sage: DihedralGroup(3)
            The 3-th dihedral group of order 6

        """
        assert n >= 2
        Parent.__init__(self, category=FiniteCoxeterGroups())
        self.n = n
예제 #59
0
    def __init__(self, roots = None, children = None, post_process = None,
                 algorithm = 'depth', facade = None, category=None):
        r"""
        TESTS::

            sage: S = SearchForest(NN, lambda x : [], lambda x: x^2 if x.is_prime() else None)
            sage: S.category()
            Category of enumerated sets
        """
        if roots is not None:
            self._roots = roots
        if children is not None:
            self.children = children
        if post_process is not None:
            self.post_process = post_process
        self._algorithm = algorithm
        Parent.__init__(self, facade = facade, category = EnumeratedSets().or_subcategory(category))
예제 #60
0
 def __init__(self, G, V, trivial_action=False):
     self._G = G
     self._V = V
     Parent.__init__(self)
     self._act = IndAction(G.large_group(),
                           self,
                           G,
                           trivial_action=trivial_action)
     quat_act = IndAction(G.large_group().B,
                          self,
                          G,
                          trivial_action=trivial_action)
     self._base_trivial_action = trivial_action
     self._unset_coercions_used()
     self.register_action(self._act)
     self.register_action(quat_act)
     self._populate_coercion_lists_()