Skip to content

Commit

Permalink
fixed importError, issue #1183
Browse files Browse the repository at this point in the history
  • Loading branch information
Abelgurung committed Mar 29, 2024
1 parent 9069571 commit 0e51095
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/cellrank/pl/_circular_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 0e51095

Please sign in to comment.