Skip to content

Commit b929618

Browse files
committed
Fix *Numpy* 2.0 incompatibility issue.
1 parent 4df372b commit b929618

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

colour_datasets/loaders/hung1995.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,28 @@ def load(
147147
for filename in filenames:
148148
datafile_path = os.path.join(self.record.repository, "dataset", filename)
149149

150-
self._content[filename.split(".")[0]] = np.genfromtxt(
150+
data = np.genfromtxt(
151151
datafile_path,
152152
delimiter=",",
153153
names=True,
154154
dtype=None,
155155
encoding="utf-8",
156156
)
157157

158+
# NOTE: Convert numpy integer dtypes to Python int (object dtype)
159+
# to avoid NumPy 2.x dtype conversion issues on Linux
160+
if data.dtype.names:
161+
new_dtype = []
162+
for name in data.dtype.names:
163+
dtype = data.dtype[name]
164+
if np.issubdtype(dtype, np.integer):
165+
new_dtype.append((name, object))
166+
else:
167+
new_dtype.append((name, dtype))
168+
data = data.astype(new_dtype, copy=False)
169+
170+
self._content[filename.split(".")[0]] = data
171+
158172
hues = [
159173
"Red",
160174
"Red-yellow",

0 commit comments

Comments
 (0)