Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add input image array shape check #54

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/sharpedge/_utils/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ def _input_checker(img_array):
# Check the image format: must be a numpy array
if not isinstance(img_array, np.ndarray):
raise TypeError("Image format must be a numpy array.")
# Check input image array shape
if not (img_array.ndim == 2 or (img_array.ndim == 3 and img_array.shape[2] == 3)):
raise ValueError(
f"Invalid image shape: {img_array.shape}. "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be an indention issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. thanks for point it out. I have fixed it.

"Expected 2D (grayscale) or 3D with 3 channels (RGB)."
)
Loading