Array
Represents an arbitrary NumPy ndarray (1D, 2D, 3D, or higher). Supports to_numpy() for direct access. This datatype is used for generic array data transport within the Telekinesis ecosystem.
Field
Required
| Field | Type | Description |
|---|---|---|
value | np.ndarray | The wrapped NumPy array. Arbitrary shape and dtype (e.g. float32, int32). |
Optional
None.
Methods
| Method | Description |
|---|---|
to_numpy() | Returns the underlying NumPy array. |
Example
From the datatypes examples:
python
import numpy as np
from datatypes import datatypes
from loguru import logger
# ------------------------------------------------
# 1. Create Array instance (1D)
# ------------------------------------------------
arr_1d = np.array([1.0, 2.0, 3.0, 4.0], dtype=np.float32)
array_1d = datatypes.Array(arr_1d)
# ------------------------------------------------
# 2. Access data via to_numpy and to_list (1D case)
# ------------------------------------------------
data = array_1d.to_numpy()
logger.info("Array (1D) to_numpy shape={}", data.shape)
logger.info("Array (1D) to_numpy dtype={}", data.dtype)
logger.info("Array (1D) to_list={}", array_1d.to_list())
# ------------------------------------------------
# 3. Create Array instance (2D)
# ------------------------------------------------
arr_2d = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.int32)
array_2d = datatypes.Array(arr_2d)
# ------------------------------------------------
# 4. Access data via to_numpy and to_list (2D case)
# ------------------------------------------------
numpy_arr = array_2d.to_numpy()
logger.info("Array (2D) to_numpy shape={}", numpy_arr.shape)
logger.info("Array (2D) to_numpy dtype={}", numpy_arr.dtype)
logger.info("Array (2D) to_list={}", array_2d.to_list())
# ------------------------------------------------
# 5. Create Array instance (3D)
# ------------------------------------------------
arr_3d = np.random.randn(2, 3, 4).astype(np.float32)
array_3d = datatypes.Array(arr_3d)
# ------------------------------------------------
# 6. Access data via to_numpy and to_list (3D case)
# ------------------------------------------------
data_3d = array_3d.to_numpy()
logger.info("Array (3D) to_numpy shape={}", data_3d.shape)
logger.info("Array (3D) to_numpy dtype={}", data_3d.dtype)
logger.info("Array (3D) to_list len={}", len(array_3d.to_list()))
