本文整理汇总了Python中sage.modules.free_module.VectorSpace.set_immutable方法的典型用法代码示例。如果您正苦于以下问题:Python VectorSpace.set_immutable方法的具体用法?Python VectorSpace.set_immutable怎么用?Python VectorSpace.set_immutable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.modules.free_module.VectorSpace
的用法示例。
在下文中一共展示了VectorSpace.set_immutable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sage.modules.free_module import VectorSpace [as 别名]
# 或者: from sage.modules.free_module.VectorSpace import set_immutable [as 别名]
def __init__(self, surface, label, point, ring = None, limit=None):
self._s = surface
if ring is None:
self._ring = surface.base_ring()
else:
self._ring = ring
p = surface.polygon(label)
point = VectorSpace(self._ring,2)(point)
point.set_immutable()
pos = p.get_point_position(point)
assert pos.is_inside(), \
"Point must be positioned within the polygon with the given label."
# This is the correct thing if point lies in the interior of the polygon with the given label.
self._coordinate_dict = {label: {point}}
if pos.is_in_edge_interior():
label2,e2 = surface.opposite_edge(label, pos.get_edge())
point2 = surface.edge_transformation(label, pos.get_edge())(point)
point2.set_immutable()
if label2 in self._coordinate_dict:
self._coordinate_dict[label2].add(point2)
else:
self._coordinate_dict[label2]={point2}
if pos.is_vertex():
self._coordinate_dict = {}
sing = surface.singularity(label, pos.get_vertex(), limit=limit)
for l,v in sing.vertex_set():
new_point = surface.polygon(l).vertex(v)
new_point.set_immutable()
if l in self._coordinate_dict:
self._coordinate_dict[l].add(new_point)
else:
self._coordinate_dict[l] = {new_point}
# Freeze the sets.
for label,point_set in self._coordinate_dict.iteritems():
self._coordinate_dict[label] = frozenset(point_set)