diff --git a/src/cellcharter/tl/_autok.py b/src/cellcharter/tl/_autok.py index cd35576..a0eeca0 100644 --- a/src/cellcharter/tl/_autok.py +++ b/src/cellcharter/tl/_autok.py @@ -97,7 +97,6 @@ def fit(self, adata: ad.AnnData, use_rep: str = "X_cellcharter"): use_rep Key in :attr:`anndata.AnnData.obsm` to use as data to fit the clustering model. If ``None``, uses :attr:`anndata.AnnData.X`. """ - if use_rep not in adata.obsm: raise ValueError(f"{use_rep} not found in adata.obsm. If you want to use adata.X, set use_rep=None") @@ -115,7 +114,7 @@ def fit(self, adata: ad.AnnData, use_rep: str = "X_cellcharter"): previous_stability = None for i in range(self.max_runs): - print(f"Iteration {i+1}/{self.max_runs}") + print(f"Iteration {i + 1}/{self.max_runs}") new_labels = {} for k in tqdm(self.n_clusters, disable=(len(self.n_clusters) == 1)): @@ -148,7 +147,7 @@ def fit(self, adata: ad.AnnData, use_rep: str = "X_cellcharter"): for k, new_l in new_labels.items(): self.labels[k].append(new_l) print( - f"Convergence with a change in stability of {stability_change} reached after {i+1} iterations" + f"Convergence with a change in stability of {stability_change} reached after {i + 1} iterations" ) break diff --git a/src/cellcharter/tl/_shape.py b/src/cellcharter/tl/_shape.py index c2dff22..f3e4fcb 100644 --- a/src/cellcharter/tl/_shape.py +++ b/src/cellcharter/tl/_shape.py @@ -167,7 +167,7 @@ def _remove_dangling_branches(graph, min_ratio=0.05): def _longest_path_from_node(graph, u): - visited = {i: False for i in list(graph.nodes)} + visited = dict.fromkeys(graph.nodes) distance = {i: -1 for i in list(graph.nodes)} idx2node = dict(enumerate(graph.nodes))