本文整理汇总了Python中vector.Vector.sum方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.sum方法的具体用法?Python Vector.sum怎么用?Python Vector.sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector.Vector
的用法示例。
在下文中一共展示了Vector.sum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import sum [as 别名]
def apply(boids, bj):
pcj = Vector()
for b in boids:
if b != bj:
pcj.sum(b.position)
pcj = pcj.div(len(boids) - 1)
return pcj.minus(bj.position).div(100)
示例2: test_sum
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import sum [as 别名]
def test_sum(self):
# Given
vector = Vector()
vector_to_sum = Vector(2, 3)
expected_x = vector.x + vector_to_sum.x
expected_y = vector.y + vector_to_sum.y
# When
vector.sum(vector_to_sum)
# Then
self.assertEquals(vector.x, expected_x)
self.assertEquals(vector.y, expected_y)
示例3: test_vector_sum_checks_shapes
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import sum [as 别名]
def test_vector_sum_checks_shapes():
"""Shape rule: the vectors must be the same size."""
Vector.sum(v, w, m, y)
示例4: test_vector_sum
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import sum [as 别名]
def test_vector_sum():
"""vector_sum can take any number of vectors and add them together."""
assert Vector.sum(v, w, u, y, z) == Vector([12, 26, 35])