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

Convert boolean mask array to int8 #2354

Merged
merged 1 commit into from
Dec 14, 2024
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
18 changes: 14 additions & 4 deletions src/pyFAI/io/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
"""Module function to read images.
"""

__author__ = "Valentin Valls"
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "11/12/2024"
__status__ = "development"


import os.path
import fabio
import silx.io
Expand All @@ -53,7 +61,7 @@ def read_data(image_path):
with fabio.open(image_path) as image:
data = image.data
else:
raise IOError("Data from path '%s' is not supported or missing" % image_path)
raise IOError(f"Data from path '{image_path}' is not supported or missing")
return data


Expand All @@ -68,7 +76,9 @@ def read_image_data(image_path):
"""
data = read_data(image_path)
if len(data.shape) != 2:
raise TypeError("Path %s identify a %dd-array, but a 2d is array is expected" % (image_path, len(data.shape)))
if data.dtype.kind not in "fui":
raise TypeError("Path %s identify an %s-kind array, but a numerical kind is expected" % (image_path, data.dtype.kind))
raise TypeError(f"Path {image_path} identify a {len(data.shape)}d-array, but a 2d is array is expected")
if data.dtype.kind == "b":
data = data.astype("int8")
elif data.dtype.kind not in "fui":
raise TypeError(f"Path {image_path} identify an {data.dtype.kind}-kind array, but a numerical kind is expected")
return data
Loading