Problem
The main goal of the Dataset class is to containerize and retrieve the underlying data, including metadata.
Currently it is forced to numpy. This deviates from the main workflow for 4D-STEM reconstructions, which primarily rely
on torch or cupy - both for using quantem directly and for algo dev in forks.
Ref:
if not isinstance(arr, np.ndarray):
raise TypeError(
"Dataset requires a NumPy array (CuPy is not supported on this branch)."
)
Two cases where I don't get to use Dataset4dstem:
Case i) When a 4D-STEM dataset is loaded via the CUDA path (#135),
wrapping it in Dataset4dstem requires converting from VRAM to CPU RAM. With a duck-typed dataset, the data can stay in
VRAM and the widget (Show4DSTEM) reads it directly, eliminating the RAM↔VRAM round trip.
Case ii) Live SSB. Detector frames stream into VRAM and are processed on the GPU - they never touch CPU RAM.
Proposed solution
Remove isinstance(arr, np.ndarray) and replace it with a minimal duck-type check.
Accept any object exposing shape, ndim, dtype, and the standard reduction methods (.sum, .mean, .max, .min).
Problem
The main goal of the Dataset class is to containerize and retrieve the underlying data, including metadata.
Currently it is forced to
numpy. This deviates from the main workflow for 4D-STEM reconstructions, which primarily relyon
torchorcupy- both for usingquantemdirectly and for algo dev in forks.Ref:
Two cases where I don't get to use
Dataset4dstem:Case i) When a 4D-STEM dataset is loaded via the CUDA path (#135),
wrapping it in
Dataset4dstemrequires converting from VRAM to CPU RAM. With a duck-typed dataset, the data can stay inVRAM and the widget (
Show4DSTEM) reads it directly, eliminating the RAM↔VRAM round trip.Case ii) Live SSB. Detector frames stream into VRAM and are processed on the GPU - they never touch CPU RAM.
Proposed solution
Remove
isinstance(arr, np.ndarray)and replace it with a minimal duck-type check.Accept any object exposing shape, ndim, dtype, and the standard reduction methods (.sum, .mean, .max, .min).