Add message on exception

This commit is contained in:
Florent Guiotte 2020-05-31 10:33:42 +02:00
parent d12afdeb91
commit 732060d160

View File

@ -42,6 +42,11 @@ def run(gt, rasters, coords, remove, attributes, adjacency='4', filtering='direc
X_raw = np.moveaxis(np.array(list(eap.vectorize())), 0, -1) X_raw = np.moveaxis(np.array(list(eap.vectorize())), 0, -1)
y_raw = gti y_raw = gti
if np.isnan(X_raw).any():
raise Exception('Found {} Nan on {}'.format(np.isnan(X_raw).sum(),
coordsi))
# Remove unwanted label X, y # Remove unwanted label X, y
lbl = np.ones_like(y_raw, dtype=np.bool) lbl = np.ones_like(y_raw, dtype=np.bool)
for l in remove if remove else []: for l in remove if remove else []:
@ -51,7 +56,7 @@ def run(gt, rasters, coords, remove, attributes, adjacency='4', filtering='direc
y += [y_raw[lbl]] y += [y_raw[lbl]]
groups += [np.repeat(coordsi, lbl.sum())] groups += [np.repeat(coordsi, lbl.sum())]
X = np.concatenate(X).astype(np.float32) X = np.concatenate(X)
y = np.concatenate(y) y = np.concatenate(y)
groups = np.concatenate(groups) groups = np.concatenate(groups)