Skip to content

Commit

Permalink
Merge branch 'main' into simplify-scale
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Nov 11, 2024
2 parents bbbf3f4 + 6dd0a7a commit 4008a28
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/scanpy/preprocessing/_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

if TYPE_CHECKING:
from numpy.typing import ArrayLike, NDArray
from numpy.typing import NDArray
from scipy import sparse as sp

CSMatrix = sp.csr_matrix | sp.csc_matrix

CSMatrix = csr_matrix | csc_matrix

Expand Down Expand Up @@ -75,6 +79,14 @@ def clip_array(
return X


def clip_set(x: CSMatrix, *, max_value: float, zero_center: bool = True) -> CSMatrix:
x = x.copy()
x[x > max_value] = max_value
if zero_center:
x[x < -max_value] = -max_value
return x


@renamed_arg("X", "data", pos_0=True)
@old_positionals("zero_center", "max_value", "copy", "layer", "obsm")
@singledispatch
Expand Down

0 comments on commit 4008a28

Please sign in to comment.