当前位置: 首页>>代码示例>>Python>>正文


Python Vector.append方法代码示例

本文整理汇总了Python中vector.Vector.append方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.append方法的具体用法?Python Vector.append怎么用?Python Vector.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vector.Vector的用法示例。


在下文中一共展示了Vector.append方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delete_many

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import append [as 别名]
def test_delete_many():
    v = Vector()
    for x in range(1000):
        v.append(x)
    c = v.capacity
    for x in range(1000):
        v.delete(v.length // 2)
    assert v.capacity < c
    assert v.length == 0
开发者ID:dbader,项目名称:data-structures-py,代码行数:11,代码来源:vector_test.py

示例2: test_delete

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import append [as 别名]
def test_delete():
    v = Vector()
    v.append(1)
    v.append(2)
    v.append(3)
    assert v.length == 3
    v.delete(1)
    assert v.length == 2
    assert v[0] == 1
    assert v[1] == 3
开发者ID:dbader,项目名称:data-structures-py,代码行数:12,代码来源:vector_test.py

示例3: test_set_item

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import append [as 别名]
def test_set_item():
    v = Vector()
    for x in range(100):
        v.append(x)
    v[0] = 991
    v[20] = 992
    v[40] = 993
    v[99] = 994
    assert v[0] == 991
    assert v[20] == 992
    assert v[40] == 993
    assert v[99] == 994
开发者ID:dbader,项目名称:data-structures-py,代码行数:14,代码来源:vector_test.py

示例4: __mul__

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import append [as 别名]
 def __mul__(self, other):
     if isinstance(other, Number):
         return np.multiply(self, other)
     elif isinstance(other, np.matrix) and other.shape[0] == 4:
         return np.matrix.__mul__(self, other)
     elif isinstance(other, (np.ndarray, list, tuple)):
         if isinstance(other, (list, tuple)):
             other = Vector(other)
         should_extend = len(other) == 3
         if should_extend:
             other = list(other)
             other.append(1)
             other = Vector(other)
         result = Vector(np.matrix.__mul__(self, other.flat).flat)
         if should_extend:
             result[0:3] /= result[3]
             return result[0:3]
         else:
             return result
     return Vector(np.matrix.__mul__(self, other).flat)
开发者ID:kanzure,项目名称:python-brlcad,代码行数:22,代码来源:transform.py

示例5: test_append

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import append [as 别名]
def test_append():
    v = Vector()
    for x in range(1000):
        v.append(x)
        assert v[x] == x
    assert v.length == 1000
开发者ID:dbader,项目名称:data-structures-py,代码行数:8,代码来源:vector_test.py


注:本文中的vector.Vector.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。