本文整理汇总了Python中sage.structure.element.Element类的典型用法代码示例。如果您正苦于以下问题:Python Element类的具体用法?Python Element怎么用?Python Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Element类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, core, parent):
"""
TESTS::
sage: C = Cores(4,3)
sage: c = C([2,1]); c
[2, 1]
sage: type(c)
<class 'sage.combinat.core.Cores_length_with_category.element_class'>
sage: c.parent()
4-Cores of length 3
sage: TestSuite(c).run()
sage: C = Cores(3,3)
sage: C([2,1])
Traceback (most recent call last):
...
ValueError: [2, 1] is not a 3-core
"""
k = parent.k
part = Partition(core)
if not part.is_core(k):
raise ValueError, "%s is not a %s-core"%(part, k)
CombinatorialObject.__init__(self, core)
Element.__init__(self, parent)
开发者ID:biasse,项目名称:sage,代码行数:25,代码来源:core.py
示例2: __init__
def __init__(self, poset, element, vertex):
r"""
Establishes the parent-child relationship between ``poset``
and ``element``, where ``element`` is associated to the
vertex ``vertex`` of the Hasse diagram of the poset.
INPUT:
- ``poset`` - a poset object
- ``element`` - any object
- ``vertex`` - a vertex of the Hasse diagram of the poset
TESTS::
sage: from sage.combinat.posets.elements import PosetElement
sage: P = Poset([[1,2],[4],[3],[4],[]], facade = False)
sage: e = P(0)
sage: e.parent() is P
True
sage: TestSuite(e).run()
"""
Element.__init__(self, poset)
if isinstance(element, self.parent().element_class):
self.element = element.element
else:
self.element = element
self.vertex = vertex
开发者ID:sageb0t,项目名称:testsage,代码行数:29,代码来源:elements.py
示例3: __init__
def __init__(self, parent, blocks):
self._blocks = blocks
self._number_of_blocks = len(blocks)
self._n = parent._n
if not SetPartitions(self._n)(self._blocks).is_noncrossing():
raise ValueError("{} is not noncrossing".format(blocks))
Element.__init__(self, parent)
开发者ID:ShuliChen,项目名称:permutation,代码行数:7,代码来源:noncrossingpartition_Element.py
示例4: __init__
def __init__(self, domain, coords=None, chart=None, name=None,
latex_name=None):
Element.__init__(self, domain)
self.manifold = domain.manifold
self.domain = domain
self.coordinates = {}
if coords is not None:
if len(coords) != self.manifold.dim:
raise ValueError("The number of coordinates must be equal" +
" to the manifold dimension.")
if chart is None:
chart = self.domain.def_chart
else:
if chart not in self.domain.atlas:
raise ValueError("The " + str(chart) +
" has not been defined on the " + str(self.domain))
#!# The following check is not performed for it would fail with
# symbolic coordinates:
# if not chart.valid_coordinates(*coords):
# raise ValueError("The coordinates " + str(coords) +
# " are not valid on the " + str(chart))
for schart in chart.supercharts:
self.coordinates[schart] = tuple(coords)
for schart in chart.subcharts:
if schart != chart:
if schart.valid_coordinates(*coords):
self.coordinates[schart] = tuple(coords)
self.name = name
if latex_name is None:
self.latex_name = self.name
else:
self.latex_name = latex_name
开发者ID:sagemanifolds,项目名称:SageManifolds,代码行数:32,代码来源:point.py
示例5: __init__
def __init__(self, model, coordinates, is_boundary, check=True, **graphics_options):
r"""
See ``HyperbolicPoint`` for full documentation.
EXAMPLES::
sage: p = HyperbolicPlane().UHP().get_point(I)
sage: TestSuite(p).run()
"""
if is_boundary:
if not model.is_bounded():
raise NotImplementedError("boundary points are not implemented in the {0} model".format(model.short_name()))
if check and not model.boundary_point_in_model(coordinates):
raise ValueError(
"{0} is not a valid".format(coordinates) +
" boundary point in the {0} model".format(model.short_name()))
elif check and not model.point_in_model(coordinates):
raise ValueError(
"{0} is not a valid".format(coordinates) +
" point in the {0} model".format(model.short_name()))
if isinstance(coordinates, tuple):
coordinates = vector(coordinates)
self._coordinates = coordinates
self._bdry = is_boundary
self._graphics_options = graphics_options
Element.__init__(self, model)
开发者ID:sagemath,项目名称:sage,代码行数:28,代码来源:hyperbolic_point.py
示例6: __init__
def __init__(self, parent, Vrep, Hrep, polymake_polytope=None, **kwds):
"""
Initializes the polyhedron.
See :class:`Polyhedron_polymake` for a description of the input
data.
TESTS:
We skip the pickling test because pickling is currently
not implemented::
sage: p = Polyhedron(backend='polymake') # optional - polymake
sage: TestSuite(p).run(skip="_test_pickling") # optional - polymake
sage: p = Polyhedron(vertices=[(1, 1)], rays=[(0, 1)], # optional - polymake
....: backend='polymake')
sage: TestSuite(p).run(skip="_test_pickling") # optional - polymake
sage: p = Polyhedron(vertices=[(-1,-1), (1,0), (1,1), (0,1)], # optional - polymake
....: backend='polymake')
sage: TestSuite(p).run(skip="_test_pickling") # optional - polymake
"""
if polymake_polytope:
if Hrep is not None or Vrep is not None:
raise ValueError("only one of Vrep, Hrep, or polymake_polytope can be different from None")
Element.__init__(self, parent=parent)
self._init_from_polymake_polytope(polymake_polytope)
else:
Polyhedron_base.__init__(self, parent, Vrep, Hrep, **kwds)
开发者ID:mcognetta,项目名称:sage,代码行数:28,代码来源:backend_polymake.py
示例7: __init__
def __init__(self, parent, data):
r"""
TESTS::
sage: T = TotallyOrderedFiniteSet([3,2,1],facade=False)
sage: TestSuite(T.an_element()).run()
"""
Element.__init__(self, parent)
self.value = data
开发者ID:DrXyzzy,项目名称:sage,代码行数:9,代码来源:totally_ordered_finite_set.py
示例8: __init__
def __init__(self, parent, key):
"""
Create a cipher.
INPUT: Parent and key
EXAMPLES: None yet
"""
Element.__init__(self, parent)
self._key = key
开发者ID:CETHop,项目名称:sage,代码行数:10,代码来源:cipher.py
示例9: __init__
def __init__(self, instance, workprec=None):
if isinstance(instance, LazyApproximationWrapper):
raise TypeError
Element.__init__(self, instance.parent())
self._instance = instance
ref = weakref.ref(self, delete_max_workprec)
wrappers[ref] = instance
self._ref = ref
if workprec is not None:
instance.update_max_workprec(workprec, wrapper=ref)
开发者ID:roed314,项目名称:padicprec,代码行数:10,代码来源:lazy.py
示例10: __init__
def __init__(self, parent, m):
r"""
EXAMPLES::
sage: B = crystals.elementary.Elementary(['B',7],7)
sage: elt = B(17); elt
17
"""
self._m = m
Element.__init__(self, parent)
开发者ID:sagemath,项目名称:sage,代码行数:10,代码来源:elementary_crystals.py
示例11: __init__
def __init__(self, parent, lst):
"""
Initialize ``self``.
EXAMPLES::
sage: C = Composition([3,1,2])
sage: TestSuite(C).run()
"""
CombinatorialObject.__init__(self, lst)
Element.__init__(self, parent)
开发者ID:odellus,项目名称:sage,代码行数:11,代码来源:composition.py
示例12: __init__
def __init__(self, parent, tau):
"""
Initialize ``self``.
EXAMPLES::
sage: elt = SimilarityClassType([[3, [3, 2, 1]], [2, [2, 1]]])
sage: TestSuite(elt).run()
"""
CombinatorialObject.__init__(self, sorted(tau, key=lambda PT: (PT.degree(), PT.partition())))
Element.__init__(self, parent)
开发者ID:jhpalmieri,项目名称:sage,代码行数:11,代码来源:similarity_class_type.py
示例13: __init__
def __init__(self, parent, vecpar):
"""
Initialize ``self``.
EXAMPLES::
sage: elt = VectorPartition([[3, 2, 1], [2, 2, 1]])
sage: TestSuite(elt).run()
"""
CombinatorialObject.__init__(self, sorted(vecpar))
Element.__init__(self, parent)
开发者ID:CETHop,项目名称:sage,代码行数:11,代码来源:vector_partition.py
示例14: __init__
def __init__(self, parent, x):
"""
Initialize ``self``.
EXAMPLES::
sage: mst = MultiSkewTableau([ [[None,1],[2,3]], [[1,2],[2]] ])
sage: TestSuite(mst).run()
"""
CombinatorialObject.__init__(self, x)
Element.__init__(self, parent)
开发者ID:acrlakshman,项目名称:sage,代码行数:11,代码来源:ribbon_tableau.py
示例15: __init__
def __init__(self, lst):
"""
TESTS::
sage: NonDecreasingParkingFunction([1, 1, 2, 2, 5, 6])
[1, 1, 2, 2, 5, 6]
"""
if not is_a(lst):
raise ValueError('%s is not a non-decreasing parking function' % lst)
parent = NonDecreasingParkingFunctions_n(len(lst))
Element.__init__(self, parent)
self._list = lst
开发者ID:sagemath,项目名称:sage,代码行数:12,代码来源:non_decreasing_parking_function.py
示例16: __init__
def __init__(self, parent):
r"""
Initialisation function.
EXAMPLE::
sage: pAdicWeightSpace(17)(0)
0
"""
Element.__init__(self, parent)
self._p = self.parent().prime()
开发者ID:bgxcpku,项目名称:sagelib,代码行数:12,代码来源:weightspace.py
示例17: __init__
def __init__(self, parent, lst):
"""
Initialize ``self``.
EXAMPLES::
sage: D = Derangements(4)
sage: elt = D([4,3,2,1])
sage: TestSuite(elt).run()
"""
CombinatorialObject.__init__(self, lst)
Element.__init__(self, parent)
开发者ID:bukzor,项目名称:sage,代码行数:12,代码来源:derangements.py
示例18: __init__
def __init__(self, parent, gap_handle):
"""
Initialize an element of ``parent``
.. TODO:: make this more robust
"""
#from sage.libs.gap.element import GapElement
#if not isinstance(gap_handle, GapElement):
# raise ValueError("Input not a GAP handle")
Element.__init__(self, parent)
GAPObject.__init__(self, gap_handle)
开发者ID:nthiery,项目名称:sage-gap-semantic-interface,代码行数:12,代码来源:mygap.py
示例19: __init__
def __init__(self, parent, t):
r"""
Initialize a composition tableau.
TESTS::
sage: t = CompositionTableaux()([[1],[2,2]])
sage: s = CompositionTableaux(3)([[1],[2,2]])
sage: s==t
True
sage: t.parent()
Composition Tableaux
sage: s.parent()
Composition Tableaux of size 3 and maximum entry 3
sage: r = CompositionTableaux()(s)
sage: r.parent()
Composition Tableaux
"""
if isinstance(t, CompositionTableau):
Element.__init__(self, parent)
CombinatorialObject.__init__(self, t._list)
return
# CombinatorialObject verifies that t is a list
# We must verify t is a list of lists
if not all(isinstance(row, list) for row in t):
raise ValueError("A composition tableau must be a list of lists.")
if not map(len,t) in Compositions():
raise ValueError("A composition tableau must be a list of non-empty lists.")
# Verify rows weakly decrease from left to right
for row in t:
if any(row[i] < row[i+1] for i in range(len(row)-1)):
raise ValueError("Rows must weakly decrease from left to right.")
# Verify leftmost column strictly increases from top to bottom
first_col = [row[0] for row in t if t!=[[]]]
if any(first_col[i] >= first_col[i+1] for i in range(len(t)-1)):
raise ValueError("Leftmost column must strictly increase from top to bottom.")
# Verify triple condition
l = len(t)
m = max(map(len,t)+[0])
TT = [row+[0]*(m-len(row)) for row in t]
for i in range(l):
for j in range(i+1,l):
for k in range(1,m):
if TT[j][k] != 0 and TT[j][k] >= TT[i][k] and TT[j][k] <= TT[i][k-1]:
raise ValueError("Triple condition must be satisfied.")
Element.__init__(self, parent)
CombinatorialObject.__init__(self, t)
开发者ID:amitjamadagni,项目名称:sage,代码行数:53,代码来源:composition_tableau.py
示例20: __init__
def __init__(self, parent, asm):
"""
Initialize ``self``.
EXAMPLES:
sage: A = AlternatingSignMatrices(3)
sage: elt = A([[1, 0, 0],[0, 1, 0],[0, 0, 1]])
sage: TestSuite(elt).run()
"""
self._matrix = asm
Element.__init__(self, parent)
开发者ID:odellus,项目名称:sage,代码行数:12,代码来源:alternating_sign_matrix.py
注:本文中的sage.structure.element.Element类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论