Skip to content

Commit 6853b34

Browse files
committed
feat: Add error handling for PCA transformation in matrix_stat function
1 parent 8b16fed commit 6853b34

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

vbi/feature_extraction/features_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,12 @@ def matrix_stat(
737737
labels.extend([f"quantile_{i}" for i in quantiles])
738738

739739
if pca_num_components:
740-
pca = PCA(n_components=pca_num_components)
741-
pca_a = pca.fit_transform(A)
740+
try:
741+
pca = PCA(n_components=pca_num_components)
742+
pca_a = pca.fit_transform(A)
743+
except:
744+
return [np.nan], ["pca_error"]
745+
742746
for f in features:
743747
v = eval(f)(pca_a.reshape(-1))
744748
values.append(v)

0 commit comments

Comments
 (0)