From 6cdf32b0ebf3f5cc5031cb10f4d22d5b1cb46df3 Mon Sep 17 00:00:00 2001 From: Lukas Heumos Date: Mon, 18 May 2026 11:31:26 +0200 Subject: [PATCH 1/2] fix ci Signed-off-by: Lukas Heumos --- pertpy/tools/_perturbation_space/_perturbation_space.py | 8 ++++---- pertpy/tools/_perturbation_space/_simple.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pertpy/tools/_perturbation_space/_perturbation_space.py b/pertpy/tools/_perturbation_space/_perturbation_space.py index 026fdea0..e3850664 100644 --- a/pertpy/tools/_perturbation_space/_perturbation_space.py +++ b/pertpy/tools/_perturbation_space/_perturbation_space.py @@ -233,11 +233,11 @@ def add( new_perturbation.obs = new_obs for key, value in data["layers"].items(): - key_name = key.removesuffix("_control_diff") if key.endswith("_control_diff") else key + key_name = key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key new_perturbation.layers[key_name] = value for key, value in data["embeddings"].items(): - key_name = key.removesuffix("_control_diff") if key.endswith("_control_diff") else key + key_name = key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key new_perturbation.obsm[key_name] = value new_perturbation.obs[target_col] = new_perturbation.obs_names.astype("category") @@ -336,11 +336,11 @@ def subtract( new_perturbation.obs = new_obs for key, value in data["layers"].items(): - key_name = key.removesuffix("_control_diff") if key.endswith("_control_diff") else key + key_name = key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key new_perturbation.layers[key_name] = value for key, value in data["embeddings"].items(): - key_name = key.removesuffix("_control_diff") if key.endswith("_control_diff") else key + key_name = key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key new_perturbation.obsm[key_name] = value new_perturbation.obs[target_col] = new_perturbation.obs_names.astype("category") diff --git a/pertpy/tools/_perturbation_space/_simple.py b/pertpy/tools/_perturbation_space/_simple.py index 6db0374a..5f8f3d95 100644 --- a/pertpy/tools/_perturbation_space/_simple.py +++ b/pertpy/tools/_perturbation_space/_simple.py @@ -171,6 +171,9 @@ def compute( if mode in ps_adata.layers: ps_adata.X = ps_adata.layers[mode] + if None in ps_adata.layers: + del ps_adata.layers[None] + missing_cols = [col for col in original_obs.columns if col not in ps_adata.obs.columns] new_cols_data = {} From b3f65a2c59dfe3dcfb30d6c1f506eff55bd68d80 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 May 2026 09:32:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../_perturbation_space/_perturbation_space.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pertpy/tools/_perturbation_space/_perturbation_space.py b/pertpy/tools/_perturbation_space/_perturbation_space.py index e3850664..4336623d 100644 --- a/pertpy/tools/_perturbation_space/_perturbation_space.py +++ b/pertpy/tools/_perturbation_space/_perturbation_space.py @@ -233,11 +233,15 @@ def add( new_perturbation.obs = new_obs for key, value in data["layers"].items(): - key_name = key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key + key_name = ( + key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key + ) new_perturbation.layers[key_name] = value for key, value in data["embeddings"].items(): - key_name = key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key + key_name = ( + key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key + ) new_perturbation.obsm[key_name] = value new_perturbation.obs[target_col] = new_perturbation.obs_names.astype("category") @@ -336,11 +340,15 @@ def subtract( new_perturbation.obs = new_obs for key, value in data["layers"].items(): - key_name = key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key + key_name = ( + key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key + ) new_perturbation.layers[key_name] = value for key, value in data["embeddings"].items(): - key_name = key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key + key_name = ( + key.removesuffix("_control_diff") if isinstance(key, str) and key.endswith("_control_diff") else key + ) new_perturbation.obsm[key_name] = value new_perturbation.obs[target_col] = new_perturbation.obs_names.astype("category")