mo-vector
raw JSON → 0.1.13 verified Fri May 01 auth: no python
mo-vector is a Python library providing efficient vector operations and support for vector data structures, built on top of mo-libs. The latest version is 0.1.13, with a focus on numerical computing and data manipulation. Development is active, with releases on PyPI.
pip install mo-vector Common errors
error ModuleNotFoundError: No module named 'mo' ↓
cause Importing using incorrect dotted path instead of underscore.
fix
Install mo-vector and use
from mo_vector import vector. error TypeError: 'vector' object does not support indexing ↓
cause Attempting to index a vector like a list.
fix
Use
.values attribute or list(vector) to get indexable object. error AttributeError: 'list' object has no attribute 'dot' ↓
cause Trying to call .dot() on a Python list instead of a mo_vector object.
fix
Convert the list to a vector:
vector(mylist).dot(other_vector). Warnings
breaking Version 0.1.0 changed the import structure from dot-separated packages to underscores. Old imports like `from mo.vector import vector` will break. ↓
fix Use `from mo_vector import vector` instead.
deprecated The `vector` class's `__add__` method previously returned a new list. As of 0.1.10, it returns a `vector` object. Code relying on list output may break. ↓
fix If you need a list, call `list(result)` explicitly.
gotcha Vector operations (addition, multiplication) are element-wise by default, not matrix multiplication. Use `@` operator for dot product if available, or `.dot()` method. ↓
fix Use `v1 @ v2` or `v1.dot(v2)` for dot product.
Imports
- vector wrong
from mo.vector import vectorcorrectfrom mo_vector import vector
Quickstart
from mo_vector import vector
# Create a vector
v = vector([1, 2, 3])
print(v) # Output: [1, 2, 3]
# Vector operations
v2 = vector([4, 5, 6])
print(v + v2) # Addition
print(v * 2) # Scalar multiplication
# Dot product
print(v.dot(v2))