Skip to content

Commit c579e5b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 526c9d3 commit c579e5b

8 files changed

Lines changed: 24 additions & 41 deletions

File tree

src/decoupler/bm/_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ def _metric_scores(
139139
verbose: bool,
140140
**kwargs,
141141
) -> None:
142-
assert isinstance(metrics, str | list) or metrics is None, 'metrics must be str or list'
142+
assert isinstance(metrics, str | list) or metrics is None, "metrics must be str or list"
143143
if metrics is None:
144-
metrics = ['auc', 'fscore', 'qrank']
144+
metrics = ["auc", "fscore", "qrank"]
145145
elif isinstance(metrics, str):
146146
metrics = [metrics]
147147
if runby == "expr":

src/decoupler/mt/_gsva.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ def _dos_srs(r):
193193

194194

195195
@nb.njit(parallel=True, cache=True)
196-
def _rankmat(
197-
mat: np.ndarray
198-
) -> tuple[np.ndarray, np.ndarray]:
196+
def _rankmat(mat: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
199197
n_rows, n_cols = mat.shape
200198
dos_mat = np.zeros((n_rows, n_cols), dtype=np.int_)
201199
srs_mat = np.zeros((n_rows, n_cols), dtype=np.int_)

src/decoupler/mt/_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def _run(
5151
empty: bool = True,
5252
bsize: int | float = 250_000,
5353
verbose: bool = False,
54-
**kwargs
54+
**kwargs,
5555
) -> tuple[pd.DataFrame, pd.DataFrame] | AnnData | None:
56-
_log(f'{name} - Running {name}', level='info', verbose=verbose)
56+
_log(f"{name} - Running {name}", level="info", verbose=verbose)
5757
# Process data
5858
mat, obs, var = extract(data, layer=layer, raw=raw, empty=empty, verbose=verbose)
5959
sparse = sps.issparse(mat)

src/decoupler/mt/_viper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _shadow_regulon(
111111
net: np.ndarray,
112112
reg_sign: float = 1.96,
113113
n_targets: int | float = 10,
114-
penalty: int | float = 20
114+
penalty: int | float = 20,
115115
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
116116
# Find significant activities
117117
msk_sign = np.abs(nes_i) > reg_sign

src/decoupler/pl/_barplot.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010

1111

1212
def _set_limits(
13-
vmin: int | float,
14-
vcenter: int | float,
15-
vmax: int | float,
16-
values: np.ndarray
13+
vmin: int | float, vcenter: int | float, vmax: int | float, values: np.ndarray
1714
) -> tuple[float, float, float]:
18-
assert np.isfinite(values).all(), 'values in data mut be finite'
19-
assert isinstance(vmin, int | float) or vmin is None, 'vmin must be numerical or None'
20-
assert isinstance(vcenter, int | float) or vcenter is None, 'vcenter must be numerical or None'
21-
assert isinstance(vmax, int | float) or vmax is None, 'vmax must be numerical or None'
15+
assert np.isfinite(values).all(), "values in data mut be finite"
16+
assert isinstance(vmin, int | float) or vmin is None, "vmin must be numerical or None"
17+
assert isinstance(vcenter, int | float) or vcenter is None, "vcenter must be numerical or None"
18+
assert isinstance(vmax, int | float) or vmax is None, "vmax must be numerical or None"
2219
if vmin is None:
2320
vmin = values.min()
2421
if vmax is None:

src/decoupler/pl/_leading_edge.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212

1313
@docs.dedent
1414
def leading_edge(
15-
df: pd.DataFrame,
16-
net: pd.DataFrame,
17-
stat: str,
18-
name: str,
19-
cmap='RdBu_r',
20-
color='#88c544',
21-
**kwargs
15+
df: pd.DataFrame, net: pd.DataFrame, stat: str, name: str, cmap="RdBu_r", color="#88c544", **kwargs
2216
) -> tuple[None | Figure, np.ndarray]:
2317
"""
2418
Plot the running score of GSEA.

src/decoupler/pl/_obsm.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ def _input(
1717
names: str | list | None = None,
1818
nvar: int | float | list | None = 10,
1919
) -> tuple[pd.DataFrame, pd.DataFrame]:
20-
assert isinstance(adata, AnnData), 'adata must be adata.AnnData'
21-
assert isinstance(uns_key, str) and uns_key in adata.uns, \
22-
'uns_key must be str and in adata.uns'
23-
assert isinstance(names, str | list) or names is None, \
24-
'names must be str, list or None'
25-
assert isinstance(nvar, int | float | str | list) or nvar is None, \
26-
'nvar must be numeric, list or None'
20+
assert isinstance(adata, AnnData), "adata must be adata.AnnData"
21+
assert isinstance(uns_key, str) and uns_key in adata.uns, "uns_key must be str and in adata.uns"
22+
assert isinstance(names, str | list) or names is None, "names must be str, list or None"
23+
assert isinstance(nvar, int | float | str | list) or nvar is None, "nvar must be numeric, list or None"
2724
# Filter stats by obs names
2825
stats = adata.uns[uns_key]
2926
assert hasattr(stats, "key"), "adata.uns[key] must be generated by decoupler.tl.rankby_obsm"

src/decoupler/pp/data.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ def _extract(
1414
layer: str | None = None,
1515
raw: bool = False,
1616
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
17-
assert isinstance(data, list | pd.DataFrame | AnnData), \
18-
'mat must be a list of [matrix, samples, features], pd.DataFrame (samples x features)\n\
19-
or an AnnData instance'
20-
assert layer is None or isinstance(layer, str), 'layer must be str or None'
21-
assert isinstance(raw, bool), 'raw must be bool'
17+
assert isinstance(data, list | pd.DataFrame | AnnData), (
18+
"mat must be a list of [matrix, samples, features], pd.DataFrame (samples x features)\n\
19+
or an AnnData instance"
20+
)
21+
assert layer is None or isinstance(layer, str), "layer must be str or None"
22+
assert isinstance(raw, bool), "raw must be bool"
2223
if isinstance(data, list):
2324
mat, row, col = data
2425
mat = np.array(mat)
@@ -44,13 +45,9 @@ def _extract(
4445

4546

4647
def _validate_mat(
47-
mat: np.ndarray,
48-
row: np.ndarray,
49-
col: np.ndarray,
50-
empty: bool = True,
51-
verbose: bool = False
48+
mat: np.ndarray, row: np.ndarray, col: np.ndarray, empty: bool = True, verbose: bool = False
5249
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
53-
assert isinstance(empty, bool), 'empty must be bool'
50+
assert isinstance(empty, bool), "empty must be bool"
5451
# Accept any sparse format but transform to csr
5552
if sps.issparse(mat) and not isinstance(mat, sps.csr_matrix):
5653
mat = sps.csr_matrix(mat)

0 commit comments

Comments
 (0)