webknossos.geometry.vec_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)
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 a replaced element at a given index.
Checks if all elements in the vector are positive.
Args:
- strictly_positive (bool): If True, checks if all elements are strictly positive.
Returns:
- bool: True if all elements are positive, False otherwise.
Returns a new VecInt with the ceil division of each element by the other.
Returns a new VecInt with the maximum of each pair of elements from the two vectors.
Returns a new VecInt with the minimum of each pair of elements from the two vectors.
Adds two VecInts or returns None if the other is None.
Args:
- other (Optional[VecInt]): The other vector to add.
Returns:
- Optional[VecInt]: The sum of the two vectors or None if the other is None.
Allows to move one element at index source
to another index target
. Similar to
np.moveaxis, this is not a swap operation but instead it moves the specified
source so that the other elements move when necessary.
Args:
- source (Union[int, List[int]]): The index of the element to move.
- target (Union[int, List[int]]): The index where the element should be moved to.
Returns:
- VecInt: A new vector with the moved element.
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
- builtins.tuple
- index
- count