diff --git a/pymmcore/__init__.pyi b/pymmcore/__init__.pyi index 377dc2c..1f034f3 100644 --- a/pymmcore/__init__.pyi +++ b/pymmcore/__init__.pyi @@ -11,6 +11,8 @@ from typing import Any, Final, List, Literal, overload, Sequence, Tuple, Union from typing_extensions import deprecated import numpy as np +import numpy.typing as npt + AfterLoadSequence: int AfterSet: int @@ -1016,7 +1018,7 @@ class CMMCore: """For SLM devices with build-in light source (such as projectors), this will set the exposure time, but not (yet) start the illumination""" @overload - def setSLMImage(self, slmLabel: str, pixels: np.ndarray[Any, np.dtype[np.uint8]]) -> None: + def setSLMImage(self, slmLabel: str, pixels: npt.NDArray[np.uint8]) -> None: """ Write a 8-bit grayscale image to the SLM. Pixels must be a 2D numpy array [h,w] of uint8s. @@ -1025,7 +1027,7 @@ class CMMCore: SLM might convert grayscale to binary internally. """ @overload - def setSLMImage(self, slmLabel: str, pixels: np.ndarray[Any, np.dtype[np.uint8]] -> None: + def setSLMImage(self, slmLabel: str, pixels: npt.NDArray[np.uint8]) -> None: """ Write a color image to the SLM (imgRGB32). The pixels must be 3D numpy array [h,w,c] of uint8s with 3 color channels [R,G,B]. diff --git a/pymmcore/pymmcore_swig.i b/pymmcore/pymmcore_swig.i index df628a4..893c324 100755 --- a/pymmcore/pymmcore_swig.i +++ b/pymmcore/pymmcore_swig.i @@ -215,7 +215,7 @@ import_array(); { // Check if pixels is a numpy array if (!PyArray_Check(pixels)) { - throw CMMError("Pixels must be a numpy array"); + throw CMMError("Pixels must be a 2D numpy array [h,w] of uint8, or a 3D numpy array [h,w,c] of uint8 with 3 color channels [R,G,B]. Received a non-numpy array."); } // Get the dimensions of the numpy array