# webknossos.geometry.vec_int

class VecInt(builtins.tuple):

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)
``````
axes: Tuple[str, ...]
x: int

Returns the x component of the vector.

y: int

Returns the y component of the vector.

z: int

Returns the z component of the vector.

@staticmethod
def from_str(string: str

Returns a new ND Vector from a string representation.

Args:

• string (str): The string representation of the vector.

Returns:

• VecInt: The new vector.
def with_replaced(self: ~_T, index: int, new_element: int) -> ~_T:

Returns a new ND Vector with a replaced element at a given index.

def to_np(self) -> numpy.ndarray:

Returns the vector as a numpy array.

def to_list(self) -> List[int]:

Returns the vector as a list.

def to_tuple(self) -> Tuple[int, ...]:

Returns the vector as a tuple.

def contains(self, needle: int) -> bool:

Checks if the vector contains a given element.

def is_positive(self, strictly_positive: bool = False) -> bool:

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.
def is_uniform(self) -> bool:

Checks if all elements in the vector are the same.

def ceildiv( self: ~_T, other: Union[int, Union[webknossos.geometry.vec_int.VecInt, Tuple[int, ...], numpy.ndarray, Iterable[int]]]) -> ~_T:

Returns a new VecInt with the ceil division of each element by the other.

def pairmax( self: ~_T, other: Union[int, Union[webknossos.geometry.vec_int.VecInt, Tuple[int, ...], numpy.ndarray, Iterable[int]]]) -> ~_T:

Returns a new VecInt with the maximum of each pair of elements from the two vectors.

def pairmin( self: ~_T, other: Union[int, Union[webknossos.geometry.vec_int.VecInt, Tuple[int, ...], numpy.ndarray, Iterable[int]]]) -> ~_T:

Returns a new VecInt with the minimum of each pair of elements from the two vectors.

def prod(self) -> int:

Returns the product of all elements in the vector.

def add_or_none( self: ~_T, other: Union[webknossos.geometry.vec_int.VecInt, NoneType]) -> Union[~_T, NoneType]:

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.
def moveaxis( self: ~_T, source: Union[int, List[int]], target: Union[int, List[int]]) -> ~_T:

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.
@classmethod
def zeros(cls, axes: Tuple[str, ...]

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.
@classmethod
def ones(cls, axes: Tuple[str, ...]

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.
@classmethod
def full( cls, an_int: int, axes: Tuple[str, ...]

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
VecIntLike = typing.Union[webknossos.geometry.vec_int.VecInt, typing.Tuple[int, ...], numpy.ndarray, typing.Iterable[int]]