arrscope
Visualize n-dimensional arrays in the terminal and Jupyter — with structural trees, tiled mosaics, array diffing, and distribution sparklines.
from arrscope import scope
import numpy as np
scope(np.random.rand(3, 4, 5))
Features
- 1D → 6D+: Tiered visual grammar — lists, grids, trees, nested layers
- Named axes: Attach semantics (
batch,heads,h,w) - Four color modes:
dtype— semantic colors by data type (blue=float, green=int, …)heatmap— diverging colormap (red → light → blue) by valuesparsity— zeros as·, non-zeros in bolddiff— compare with a reference array (red=increased, blue=decreased, grey=unchanged)
- Two render styles:
tree(default) — hierarchical branch view with colored guide linesmosaic— all 2D sub-slices tiled side by side as numeric tables
- Distribution sparkline: every output shows a unicode histogram (
▁▂▃▄▅▆▇█) of value distribution — replaces text stats - Source-expression labels: like icecream's
ic(),scope(np.ones((4, 5)))auto-labels the output withnp.ones((4, 5))when you don't passtitle= - Array diffing: pass
reference=to compare any two arrays. Color-coded per-cell changes + aggregate metrics (MSE, % changed) - Head/tail truncation: large dims show first/last N slices with
…(default 20) - Smart precision: auto-detects significant figures for floats
- Terminal + Jupyter: Rich ANSI + static HTML/CSS with dark mode auto-detect
- Multi-framework: NumPy, PyTorch, TensorFlow, JAX, tinygrad (lazy imports)
- Zero config: color always on, stats always on, auto-detect terminal vs notebook
Install
pip install arrscope
Only requires numpy + rich + executing. Torch/TF/JAX/tinygrad are optional.
Quick start
from arrscope import scope
import numpy as np
# Auto-detect — last 2 dims form the grid
scope(np.random.rand(3, 4, 5))
# Named axes
scope(
np.random.rand(2, 8, 32, 32),
axes=['batch', 'heads', 'h', 'w'],
grid=['h', 'w'],
title='Attention heads',
)
# Custom grid dims
scope(data, axes=['a', 'b', 'c', 'd'], grid=['a', 'b'])
# Method chaining
r = scope(arr, mode='heatmap')
print(r.tree())
print(r.mosaic())
Source-expression labels
When you don't pass title=, arrscope inspects the call site and labels the
output with the expression you passed in — the same trick icecream.ic()
uses:
scope(np.ones((4, 5, 6, 3))) # labeled "np.ones((4, 5, 6, 3))"
scope(weights) # labeled "weights"
scope(x, title="Custom") # explicit title always wins
Falls back to no label (never raises) when the source isn't available, e.g.
in a plain REPL or python -c.
Color modes
scope(arr, mode='dtype') # default — blue floats, green ints, ...
scope(arr, mode='heatmap') # diverging colormap by value
scope(arr, mode='sparsity') # · for zeros, bold for non-zeros
scope(arr, mode='diff', # red/blue by change direction
reference=original_array) # Δ -0.5 ▁▂▃▄▅▆▇█ +0.5 mse=0.02 12% changed
Array diffing
Compare any two arrays of the same shape. Values show the current array; color encodes the change:
before = np.random.rand(3, 4, 5)
after = before + np.random.normal(0, 0.1, before.shape)
scope(after, reference=before, mode="diff")
Diff stats replace the sparkline: range of deltas, MSE, and percentage of elements that changed.
Render styles
scope(arr) # tree (default) — click-to-expand layers
scope(arr, render_style='mosaic') # all sub-slices tiled side by side
CLI
arrscope 3x4x5
arrscope 2x3x32x32 --axes batch heads h w --grid h w --mode heatmap
arrscope 20x4x5 --max-height 6
Framework support
import torch; scope(torch.randn(2, 3, 4))
import tensorflow as tf; scope(tf.random.uniform((2, 3, 4)))
import jax.numpy as jnp; scope(jnp.array([[1, 2], [3, 4]]))
from tinygrad import Tensor; scope(Tensor.randn(3, 4))
API
scope(
arr,
axes=None, # list[str] — name each dimension
grid=None, # list[str | int] — which dims form the leaf grid
title=None, # str — heading above the visualization
max_height=20, # int | None — rows before truncation, None disables
fmt=None, # str — format spec like '.4f'
mode='dtype', # 'dtype' | 'heatmap' | 'sparsity' | 'diff'
render_style='tree', # 'tree' | 'mosaic'
reference=None, # array-like — reference for diff mode
)
Development
git clone https://github.com/vizarray/arrscope
cd arrscope
uv sync
uv run pytest
uv run python main.py
License
MIT
Metadata
Release files for arrscope 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| arrscope-0.5.0.tar.gz | 104.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| arrscope-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 122.7 kB
Release files / arrscope-0.5.0.tar.gz
| Download URL | arrscope-0.5.0.tar.gz |
|---|---|
| Size | 104.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d3e2f35f07b8c45c905f9392b1ff6726eb5c72c771fc7e85c7022a5d047f739
|
|
BLAKE2b-256 checksum How to use checksums |
4ab268e89298558c9d807cff400912c1f31bd7c28f92d40e83c295841b8fb09e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.9
|
Release files / arrscope-0.5.0-py3-none-any.whl
| Download URL | arrscope-0.5.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d340288d78d1edba78d740ae2786650a71c8f042b5f6e84dd86fdcfa87453252
|
|
BLAKE2b-256 checksum How to use checksums |
a706b5e4dbac952d42afc0ceae0a5a7ff7c62e898200006faca1236f024ec34c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.9
|
Security for arrscope 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.