Skip to content

Commit a740617

Browse files
committed
Update PlotFunctions.py
1 parent a021637 commit a740617

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

riskfolio/src/PlotFunctions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,6 +3185,7 @@ def plot_dendrogram(
31853185
)
31863186
else:
31873187
clustering_inds = hr.fcluster(clustering, k, criterion="maxclust")
3188+
31883189
L, M = hr.leaders(clustering, np.array(clustering_inds, dtype=np.int32))
31893190
root, nodes = hr.to_tree(clustering, rd=True)
31903191
nodes = np.array([i.dist for i in nodes])
@@ -3450,6 +3451,8 @@ def plot_network(
34503451
k, clustering_inds = af.std_silhouette_score(dist, clustering, max_k)
34513452
else:
34523453
raise ValueError("The only opt_k_method available are twodiff and stdsil")
3454+
else:
3455+
clustering_inds = hr.fcluster(clustering, k, criterion="maxclust")
34533456

34543457
clusters = {i: [] for i in np.unique(clustering_inds)}
34553458
for i, v in enumerate(clustering_inds):
@@ -4035,6 +4038,8 @@ def plot_clusters_network(
40354038
k, clustering_inds = af.std_silhouette_score(dist, clustering, max_k)
40364039
else:
40374040
raise ValueError("The only opt_k_method available are twodiff and stdsil")
4041+
else:
4042+
clustering_inds = hr.fcluster(clustering, k, criterion="maxclust")
40384043

40394044
clusters = {i: [] for i in np.unique(clustering_inds)}
40404045
for i, v in enumerate(clustering_inds):
@@ -4329,6 +4334,8 @@ def plot_clusters_network_allocation(
43294334
k, clustering_inds = af.std_silhouette_score(dist, clustering, max_k)
43304335
else:
43314336
raise ValueError("The only opt_k_method available are twodiff and stdsil")
4337+
else:
4338+
clustering_inds = hr.fcluster(clustering, k, criterion="maxclust")
43324339

43334340
clusters = {i: [] for i in np.unique(clustering_inds)}
43344341
for i, v in enumerate(clustering_inds):

0 commit comments

Comments
 (0)