webknossos.geometry.vec3_int
The VecInt class is designed to represent a vector of integers. This class is a subclass of the built-in tuple class, and it extends the functionality of tuples by providing additional methods and operations.
One of the key features of the VecInt class is that it allows for the storage of axis names along with their corresponding values.
Here is a brief example demonstrating how to use the VecInt class:
from webknossos import VecInt
# Creating a VecInt instance with 4 elements and axes x, y, z, t:
vector_1 = VecInt(1, 2, 3, 4, axes=("x", "y", "z", "t"))
# Alternative ways to create the same VecInt instance:
vector_1 = VecInt([1, 2, 3, 4], axes=("x", "y", "z", "t"))
vector_1 = VecInt(x=1, y=2, z=3, t=4)
# Creating a VecInt instance with all elements set to 1 and axes x, y, z, t:
vector_2 = VecInt.full(1, axes=("x", "y", "z", "t"))
# Asserting that all elements in vector_2 are equal to 1:
assert vector_2[0] == vector_2[1] == vector_2[2] == vector_2[3]
# Demonstrating the addition operation between two VecInt instances:
assert vector_1 + vector_2 == VecInt(2, 3, 4, 5)
Class to represent a 3D vector. Inherits from tuple and provides useful methods and operations on top.
A small usage example:
from webknossos import Vec3Int
vector_1 = Vec3Int(1, 2, 3)
vector_2 = Vec3Int.full(1)
assert vector_2.x == vector_2.y == vector_2.y
assert vector_1 + vector_2 == (2, 3, 4)
Use Vec3Int.from_xyz for fast construction.
Returns a new ND Vector from a string representation.
Args:
- string (str): The string representation of the vector.
Returns:
- VecInt: The new vector.
Returns a new ND Vector with all elements set to 0.
Args:
- axes (Tuple[str, ...]): The axes of the vector.
Returns:
- VecInt: The new vector.
Returns a new ND Vector with all elements set to 1.
Args:
- axes (Tuple[str, ...]): The axes of the vector.
Returns:
- VecInt: The new vector.
Returns a new ND Vector with all elements set to the same value.
Args:
- an_int (int): The value to set all elements to.
- axes (Tuple[str, ...]): The axes of the vector.
Returns:
- VecInt: The new vector.
Inherited Members
- webknossos.geometry.vec_int.VecInt
- axes
- with_replaced
- to_np
- to_list
- contains
- is_positive
- is_uniform
- ceildiv
- pairmax
- pairmin
- prod
- add_or_none
- moveaxis
- builtins.tuple
- index
- count