Skip to content

Commit

Permalink
Fix DataFrame.applymap
Browse files Browse the repository at this point in the history
  • Loading branch information
michalk8 committed Nov 2, 2023
1 parent 96e22c8 commit 8043c9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cellrank/pl/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ def is_valid(x: Union[BaseModel, BulkRes]) -> bool:
return x.x_test is not None and x.y_test is not None and np.all(np.isfinite(x.y_test))

modelmat = pd.DataFrame(models).T
modelmask = modelmat.apply(is_valid)
# `DataFrame.map` in `pandas>=2.1.0`
modelmask = modelmat.map(is_valid) if hasattr(modelmat, "map") else modelmat.applymap(is_valid)
to_keep = modelmask[modelmask.any(axis=1)]
to_keep = to_keep.loc[:, to_keep.any(axis=0)].T

Expand Down
4 changes: 2 additions & 2 deletions tests/test_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,9 @@ def test_read_correct_from_layers(
adata.obsm[vkey] = adata.layers[vkey][:, : adata.obsm[xkey].shape[1]]
nans_v = np.isnan(np.sum(adata.obsm[vkey], axis=0))

gene_subset = adata.var[f"{vkey}_genes"]
gene_subset = adata.var[f"{vkey}_genes"].copy()
if use_gene_subset:
gene_subset[10:] = False
gene_subset.iloc[10:] = False
else:
gene_subset = None

Expand Down

0 comments on commit 8043c9c

Please sign in to comment.