Skip to content

numojo.core.indexing.utility

Utility functions (numojo.core.indexing.utility)

Implements N-DIMENSIONAL ARRAY UTILITY FUNCTIONS

SECTIONS OF THE FILE: 1. NDArray dtype conversions. 2. Numojo.NDArray to other collections. 3. Miscellaneous utility functions.

Aliases

newaxis

comptime newaxis

Value: NewAxis()

Structs

NewAxis

struct NewAxis

Memory convention: memory_only
Implements: AnyType, ImplicitlyDestructible, Stringable

Aliases

__del__is_trivial
comptime __del__is_trivial

Value: True

Methods

__init__
__init__(out self)

static

Initializes a NewAxis instance.

Args:

  • self (Self) [out]

Returns:

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

Checks equality between two NewAxis instances.

Args:

  • self (Self)
  • other (Self)

Returns:

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

Checks inequality between two NewAxis instances.

Args:

  • self (Self)
  • other (Self)

Returns:

  • Bool
__repr__
__repr__(self) -> String

Returns a string representation of the NewAxis instance.

Args:

  • self (Self)

Returns:

  • String
__str__
__str__(self) -> String

Returns a string representation of the NewAxis instance.

Args:

  • self (Self)

Returns:

  • String

Functions

bool_to_numeric

bool_to_numeric[dtype: DType](array: NDArray[DType.bool]) -> NDArray[dtype]

Convert a boolean NDArray to a numeric NDArray.

Parameters:

  • dtype (DType): The data type of the output NDArray elements.

Args:

  • array (NDArray): The boolean NDArray to convert.

Returns:

  • NDArray

Raises

to_numpy

to_numpy[dtype: DType](array: NDArray[dtype]) -> PythonObject

Convert a NDArray to a numpy array.

Example:

var arr = NDArray[DType.float32](3, 3, 3)
var np_arr = to_numpy(arr)
var np_arr1 = arr.to_numpy()

Parameters:

  • dtype (DType): The data type of the NDArray elements.

Args:

  • array (NDArray): The NDArray to convert.

Returns:

  • PythonObject

Raises