Skip to content

Commit

Permalink
changed to numpy.typing for stubs, changed err msg
Browse files Browse the repository at this point in the history
  • Loading branch information
hinderling committed Oct 11, 2023
1 parent faf4635 commit 8ed0cd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pymmcore/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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].
Expand Down
2 changes: 1 addition & 1 deletion pymmcore/pymmcore_swig.i
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8ed0cd7

Please sign in to comment.