Skip to content

numojo.core.indexing.slicing

Slicing (numojo.core.indexing.slicing)

This module defines internal data structures and utilities for handling slicing operations in NuMojo.

Structs

IndexTypeInfo

struct IndexTypeInfo

Memory convention: memory_only
Implements: AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable

Fields

  • is_integer (Bool)
  • is_slice (Bool)
  • is_ellipsis (Bool)
  • is_newaxis (Bool)

Aliases

__del__is_trivial
comptime __del__is_trivial

Value: True

__move_ctor_is_trivial
comptime __move_ctor_is_trivial

Value: True

__copy_ctor_is_trivial
comptime __copy_ctor_is_trivial

Value: True

Methods

__init__
__init__(out self, is_integer: Bool = False, is_slice: Bool = False, is_ellipsis: Bool = False, is_newaxis: Bool = False)

static

Args:

  • is_integer (Bool)
  • is_slice (Bool)
  • is_ellipsis (Bool)
  • is_newaxis (Bool)
  • self (Self) [out]

Returns:

  • Self
__repr__
__repr__(self) -> String

Args:

  • self (Self)

Returns:

  • String
__str__
__str__(self) -> String

Args:

  • self (Self)

Returns:

  • String
size
size(self) -> Int

Returns the number of active index types in this IndexTypeInfo.

Args:

  • self (Self)

Returns:

  • Int

InternalSlice

struct InternalSlice

Memory convention: memory_only
Implements: AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable

Fields

  • start (Int)
  • end (Int)
  • step (Int)

Aliases

__del__is_trivial
comptime __del__is_trivial

Value: True

__move_ctor_is_trivial
comptime __move_ctor_is_trivial

Value: True

__copy_ctor_is_trivial
comptime __copy_ctor_is_trivial

Value: True

Methods

__init__
__init__(out self, start: Int, end: Int, step: Int)

static

Args:

  • start (Int)
  • end (Int)
  • step (Int)
  • self (Self) [out]

Returns:

  • Self
__eq__
__eq__(self, other: Self) -> Bool

Args:

  • self (Self)
  • other (Self)

Returns:

  • Bool
__ne__
__ne__(self, other: Self) -> Bool

Args:

  • self (Self)
  • other (Self)

Returns:

  • Bool
__repr__
__repr__(self) -> String

Args:

  • self (Self)

Returns:

  • String
__str__
__str__(self) -> String

Args:

  • self (Self)

Returns:

  • String
to_tuple
to_tuple(self) -> Tuple[Int, Int, Int]

Args:

  • self (Self)

Returns:

  • Tuple
to_slice
to_slice(self) -> Slice

Args:

  • self (Self)

Returns:

  • Slice
normalize
normalize(self, dim: Int) -> Self

Args:

  • self (Self)
  • dim (Int)

Returns:

  • Self
check_bounds
check_bounds(self, dim: Int)

Args:

  • self (Self)
  • dim (Int)

Raises

get_slice_info
Overload 1
get_slice_info(s: Slice, dim: Int) -> Tuple[Int, Int, Int, Int]

static

Get complete slice information for a given dimension.

Notes: For cases with step = 0, error handling should be done prior to calling this function.

Args:

  • s (Slice): The slice to process.
  • dim (Int): The dimension size to process against.

Returns:

  • Tuple
Overload 2
get_slice_info(self, dim: Int) -> Tuple[Int, Int, Int, Int]

Get complete slice information for a given dimension.

Args:

  • self (Self)
  • dim (Int): The dimension size to process against.

Returns:

  • Tuple