NumPy Visualization

The core of Svetoviz is its ability to handle raw NumPy arrays of any dimension and data type. Whether you are inspecting a single tensor or a collection of disparate arrays, the engine provides 3D spatial awareness for every element.

Single Array Inspection

Use array to project a single NumPy array into the 3D scene. The gap_size parameter allows you to control the visual spacing between high-dimensional slices, making it easier to identify patterns across tensors.

single_array.py
import svetoviz_webgpu as sv

data = np.random.rand(4, 4, 32, 32).astype(np.float32)

sv.array(data, gap_size=10)
Single Array Visualization

Dimensional Stacking & Colormaps

Svetoviz handles high-dimensional tensors by "stacking" them along specific axes. This transforms multidimensional data into a physical 3D structure where numerical values are mapped to visual gradients in real-time.

Dimensional Stacking
Dimensional Stacking
Colormap Application
Colormap Application

Visualizing Multiple Data Types

Svetoviz supports the full spectrum of NumPy dtypes—from standard integers and floats to complex numbers and booleans. Using arrays, you can pass a list of arrays with varying shapes and types.

multi_type_demo.py
import svetoviz_webgpu as sv

sv.arrays([
    np.random.randint(-128, 128, (128, 128), dtype=np.int8),
    np.random.randint(-32768, 32768, (16, 128, 128), dtype=np.int16),
    np.random.randint(-2147483648, 2147483648, (4, 4, 64, 64), dtype=np.int32),
    np.random.randint(-9223372036854775808, 9223372036854775807, (4, 2, 32, 64), dtype=np.int64),
    np.random.randint(0, 256, (128, 128), dtype=np.uint8),
    np.random.randint(0, 65536, (16, 128, 128), dtype=np.uint16),
    np.random.randint(0, 4294967296, (4, 4, 64, 64), dtype=np.uint32),
    np.random.randint(0, 18446744073709551615, (4, 2, 32, 64), dtype=np.uint64),
    np.random.uniform(-65504, 65504, (256, 256)).astype(np.float16),
    np.random.uniform(-1e38, 1e38, (32, 32, 32)).astype(np.float32),
    np.random.uniform(-1e307, 1e307, (4, 3, 32, 32)).astype(np.float64),
    np.random.randint(0, 256, (3, 32, 32), dtype=np.uint8),
    np.random.randint(0, 256, (16, 16, 16), dtype=np.ubyte),
    np.random.randint(-128, 128, (60, 60), dtype=np.int8),
    np.random.randint(-128, 128, (8, 2, 24, 24), dtype=np.byte),
    np.random.choice([True, False], (72, 72)).astype(np.bool_),
    np.random.randint(-32768, 32768, (4, 8, 16, 16), dtype=np.int16),
    np.random.randint(-9223372036854775808, 9223372036854775807, (64, 64), dtype=np.intp),
    np.random.randint(0, 18446744073709551615, (64, 64), dtype=np.uintp),
    (np.random.randn(32, 32) + 1j * np.random.randn(32, 32)).astype(np.complex64),
    (np.random.randn(32, 32) + 1j * np.random.randn(32, 32)).astype(np.complex128),
], gap_size=32)
Multi-Type Array Visualization

Axis Ordering & Spatial Mapping

By default, Svetoviz expects the last two dimensions of an array to represent the spatial height and width (H, W). When passing standard image data in (H, W, C) format, the engine will attempt to render the channels as the spatial grid, resulting in a distorted view.

incorrect_ordering.py
import svetoviz_webgpu as sv

# Standard PIL to NumPy conversion results in (H, W, C)
data = np.array(image)

# This will render incorrectly as it treats 'C' as part of the (H, W) pair
sv.array(data, gap_size=0)
Incorrect Axis Ordering

To resolve this, use the ordering parameter to transpose the axes for the 3D projection without modifying the original array in memory. For a standard (H, W, C) image, use ordering=(2, 0, 1) to correctly map the dimensions.

corrected_ordering.py
import svetoviz_webgpu as sv

# Standard PIL to NumPy conversion results in (H, W, C)
data = np.array(image)

# Correctly map (H, W, C) to (C, H, W) for the 3D scene
sv.array(data, gap_size=0, ordering=(2, 0, 1))
Corrected Axis Ordering

High-Dimensional Large Arrays

Svetoviz handles large arrays with ease. You can, for example, see all frames from a videoclip at once, allowing for a comprehensive spatial overview of temporal data.

video_grid.py
import svetoviz_webgpu as sv

# Load your video as a numpy array
array = video_to_5d_grid('bunny.mp4')
sv.array(array)
Large Video Array Visualization