Skip to content

Commit

Permalink
fix(plotly): dendrogram fixes added
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoDelatte committed Jan 22, 2024
1 parent 796ed1e commit 374154e
Show file tree
Hide file tree
Showing 3 changed files with 398 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/skfolio/cluster/_hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

import numpy as np
import numpy.typing as npt
import plotly.figure_factory as ff
import plotly.graph_objects as go
import scipy.cluster.hierarchy as sch
import scipy.spatial.distance as scd
import sklearn.base as skb
import sklearn.utils.validation as skv

from skfolio.utils.fixes import create_dendrogram
from skfolio.utils.stats import assert_is_distance, compute_optimal_n_clusters
from skfolio.utils.tools import AutoEnum, default_asset_names

Expand Down Expand Up @@ -245,7 +245,7 @@ def plot_dendrogram(self, heatmap: bool = True) -> go.Figure:
asset_names = default_asset_names(n_assets=n_assets)

if not heatmap:
fig = ff.create_dendrogram(
fig = create_dendrogram(
np.ones(1),
distfun=lambda x: None,
linkagefun=lambda x: linkage_matrix,
Expand All @@ -264,7 +264,7 @@ def plot_dendrogram(self, heatmap: bool = True) -> go.Figure:
return fig

# Initialize figure by creating upper dendrogram
fig = ff.create_dendrogram(
fig = create_dendrogram(
np.ones(1),
orientation="bottom",
distfun=lambda x: None,
Expand All @@ -277,7 +277,7 @@ def plot_dendrogram(self, heatmap: bool = True) -> go.Figure:
fig["data"][i]["yaxis"] = "y2"

# Create Side Dendrogram
side_dendrogram = ff.create_dendrogram(
side_dendrogram = create_dendrogram(
np.ones(1),
orientation="right",
distfun=lambda x: None,
Expand Down
3 changes: 3 additions & 0 deletions src/skfolio/utils/fixes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from skfolio.utils.fixes._dendrogram import create_dendrogram

__all__ = ["create_dendrogram"]

0 comments on commit 374154e

Please sign in to comment.