Skip to content

Commit e3708eb

Browse files
authored
Merge pull request #2195 from Foxglove144/patch-1
Fix ragged nested sequence warning
2 parents 82f8fa2 + 6250986 commit e3708eb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

art/defences/detector/poison/clustering_analyzer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ def analyze_by_size(self, separated_clusters: List[np.ndarray]) -> Tuple[np.ndar
6868
all_assigned_clean = []
6969
nb_classes = len(separated_clusters)
7070
nb_clusters = len(np.unique(separated_clusters[0]))
71-
summary_poison_clusters: np.ndarray = np.zeros((nb_classes, nb_clusters))
71+
summary_poison_clusters: np.ndarray = np.zeros((nb_classes, nb_clusters), dtype=object)
7272

7373
for i, clusters in enumerate(separated_clusters):
74-
7574
# assume that smallest cluster is poisonous and all others are clean
7675
sizes = np.bincount(clusters)
7776
total_dp_in_class = np.sum(sizes)
@@ -98,8 +97,8 @@ def analyze_by_size(self, separated_clusters: List[np.ndarray]) -> Tuple[np.ndar
9897

9998
report["Class_" + str(i)] = report_class
10099

101-
report["suspicious_clusters"] = report["suspicious_clusters"] + np.sum(summary_poison_clusters).item()
102-
return np.asarray(all_assigned_clean), summary_poison_clusters, report
100+
report["suspicious_clusters"] = report["suspicious_clusters"] + np.sum(summary_poison_clusters)
101+
return np.asarray(all_assigned_clean, dtype=object), summary_poison_clusters, report
103102

104103
def analyze_by_distance(
105104
self,
@@ -187,7 +186,7 @@ def analyze_by_distance(
187186
assigned_clean = self.assign_class(clusters, clean_clusters, np.array(poison_clusters))
188187
all_assigned_clean.append(assigned_clean)
189188

190-
all_assigned_clean_array = np.asarray(all_assigned_clean)
189+
all_assigned_clean_array = np.asarray(all_assigned_clean, dtype=object)
191190
return all_assigned_clean_array, summary_poison_clusters, report
192191

193192
def analyze_by_relative_size(

0 commit comments

Comments
 (0)