Split IF logic into two lines to avoid error
alt_cluster_method can be none AND the number of clusters can be 0. But don't
want to hit the else statement when alt_cluster_method is None
and 0 clusters.
@@ -1956,15 +1956,16 @@ class GeneratorClusters:
# This is bad. Should be setting up a dictionary of objects that picks the
# correct clustering method. Can't keep doing if statements as the number of
# methods grows. CHANGE LATER.
- if (
- self.settings["alt_cluster_method"] is None
- and num_clusters[region][tech] > 0
- ):
+ if self.settings["alt_cluster_method"] is None:
+ if num_clusters[region][tech] > 0:
clusters = cluster.KMeans(
n_clusters=num_clusters[region][tech], random_state=6
).fit(preprocessing.StandardScaler().fit_transform(grouped))
- grouped["cluster"] = clusters.labels_ + 1 # Change to 1-index for julia
+ grouped["cluster"] = (
+ clusters.labels_ + 1
+ ) # Change to 1-index for julia
+
else:
if (region in self.settings[alt_cluster_method].keys()) and (
tech
