From 0e5109577659a70e4359012d0081a5859b23f95d Mon Sep 17 00:00:00 2001 From: Abel Gurung Date: Fri, 29 Mar 2024 17:00:27 -0500 Subject: [PATCH] fixed importError, issue #1183 --- src/cellrank/pl/_circular_projection.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/cellrank/pl/_circular_projection.py b/src/cellrank/pl/_circular_projection.py index 6604070af..07ac9a820 100644 --- a/src/cellrank/pl/_circular_projection.py +++ b/src/cellrank/pl/_circular_projection.py @@ -14,7 +14,7 @@ from matplotlib.colors import LinearSegmentedColormap, LogNorm from anndata import AnnData -from scanpy._utils import deprecated_arg_names +from scanpy._utils import renamed_arg from cellrank import logging as logg from cellrank._utils import Lineage @@ -69,13 +69,15 @@ def _get_optimal_order(data: Lineage, metric: Metric_T) -> Tuple[float, np.ndarr @d.dedent -@deprecated_arg_names({"labeldistance": "label_distance", "labelrot": "label_rot"}) +@renamed_arg('labeldistance', 'label_distance') +@renamed_arg('labelrot', 'label_rot') def circular_projection( adata: AnnData, keys: Union[str, Sequence[str]], backward: bool = False, lineages: Optional[Union[str, Sequence[str]]] = None, - early_cells: Optional[Union[Mapping[str, Sequence[str]], Sequence[str]]] = None, + early_cells: Optional[Union[Mapping[str, + Sequence[str]], Sequence[str]]] = None, lineage_order: Optional[Literal["default", "optimal"]] = None, metric: Union[str, Callable, np.ndarray, pd.DataFrame] = "correlation", normalize_by_mean: bool = True, @@ -162,7 +164,8 @@ def circular_projection( if a method is present in the ``keys``. """ if label_distance is not None and label_distance < 0: - raise ValueError(f"Expected `label_distance` to be positive, found `{label_distance}`.") + raise ValueError( + f"Expected `label_distance` to be positive, found `{label_distance}`.") if label_rot is None: label_rot = LabelRot.DEFAULT @@ -194,7 +197,8 @@ def circular_projection( lineages = _unique_order_preserving(lineages) probs = probs[lineages] if probs.nlin < 3: - raise ValueError(f"Expected at least `3` lineages, found `{probs.nlin}`.") + raise ValueError( + f"Expected at least `3` lineages, found `{probs.nlin}`.") X = probs.X.copy() if normalize_by_mean: @@ -294,7 +298,8 @@ def circular_projection( rot = text.get_rotation() text.set_rotation(rot + 90 + (1 - rot // 180) * 180) elif label_rot != LabelRot.DEFAULT: - raise NotImplementedError(f"Label rotation `{label_rot}` is not yet implemented.") + raise NotImplementedError( + f"Label rotation `{label_rot}` is not yet implemented.") text.set_color(color) if not show_edges: @@ -307,7 +312,8 @@ def circular_projection( points = np.array([x, y]).T.reshape(-1, 1, 2) segments = np.concatenate([points[:-1], points[1:]], axis=1) - cmap = LinearSegmentedColormap.from_list("fate_prob_cmap", [color, probs.colors[next]], N=_N) + cmap = LinearSegmentedColormap.from_list( + "fate_prob_cmap", [color, probs.colors[next]], N=_N) lc = LineCollection(segments, cmap=cmap, zorder=-1) lc.set_array(np.linspace(0, 1, _N)) lc.set_linewidth(2)