本文整理汇总了Python中sage.structure.parent.Parent类的典型用法代码示例。如果您正苦于以下问题:Python Parent类的具体用法?Python Parent怎么用?Python Parent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
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())
开发者ID:saraedum,项目名称:sage-renamed,代码行数:35,代码来源:pari_group.py
示例2: __init__
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)] ),)
开发者ID:JoseGuzman,项目名称:sage,代码行数:26,代码来源:rc_crystal.py
示例3: __init__
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
开发者ID:mmasdeu,项目名称:darmonpoints,代码行数:30,代码来源:homology_abstract.py
示例4: __init__
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
开发者ID:DrXyzzy,项目名称:sage,代码行数:35,代码来源:family.py
示例5: __init__
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())
开发者ID:DrXyzzy,项目名称:sage,代码行数:31,代码来源:integer_range.py
示例6: __init__
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
开发者ID:vbraun,项目名称:sage,代码行数:26,代码来源:tensor_product.py
示例7: __init__
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()
开发者ID:sageb0t,项目名称:testsage,代码行数:29,代码来源:spins.py
示例8: __init__
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', {}))))
开发者ID:anuragwaliya,项目名称:sage,代码行数:28,代码来源:set_from_iterator.py
示例9: __init__
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)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:27,代码来源:colored_permutations.py
示例10: __init__
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))
开发者ID:mcognetta,项目名称:sage,代码行数:25,代码来源:hyperbolic_model.py
示例11: __init__
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)
开发者ID:roed314,项目名称:padicprec,代码行数:31,代码来源:parent_inexact.py
示例12: __init__
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)
开发者ID:jwbober,项目名称:sagelib,代码行数:33,代码来源:matrix_group.py
示例13: __init__
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
开发者ID:DrXyzzy,项目名称:sage,代码行数:27,代码来源:set.py
示例14: __init__
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
开发者ID:Etn40ff,项目名称:sage,代码行数:30,代码来源:subset.py
示例15: __init__
def __init__(self):
"""
TESTS::
sage: P = Sets().example("inherits")
"""
Parent.__init__(self, facade = IntegerRing(), category = Sets())
开发者ID:TaraFife,项目名称:sage,代码行数:7,代码来源:sets_cat.py
示例16: __init__
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_()
开发者ID:biasse,项目名称:sage,代码行数:33,代码来源:affine.py
示例17: __init__
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)
开发者ID:JoseGuzman,项目名称:sage,代码行数:27,代码来源:indexed_free_monoid.py
示例18: __init__
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)
开发者ID:bgxcpku,项目名称:sagelib,代码行数:32,代码来源:linear_extensions.py
示例19: __init__
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]]),)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:30,代码来源:kyoto_path_model.py
示例20: __init__
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())
开发者ID:chos9,项目名称:sage,代码行数:28,代码来源:rigged_configurations.py
注:本文中的sage.structure.parent.Parent类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论