Skip to content

Commit

Permalink
fixing typo in generate_pert_effects docstring; adding error handling…
Browse files Browse the repository at this point in the history
… on Callable
  • Loading branch information
cmatKhan committed Feb 15, 2024
1 parent a02475f commit d903331
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion yeastdnnexplorer/probability_models/generate_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import logging
from collections.abc import Callable

Expand Down Expand Up @@ -235,7 +236,7 @@ def default_perturbation_effect_adjustment_function(
Default function to adjust the mean of the perturbation effect based on the
enrichment score.
All functions that are passed to generate_perturbation_data() in the argument
All functions that are passed to generate_perturbation_effects() in the argument
adjustment_function must have the same signature as this function.
:param binding_enrichment_data: A tensor of enrichment scores for each gene with
Expand Down Expand Up @@ -341,6 +342,20 @@ def generate_perturbation_effects(
"noise_mean, noise_std, signal_mean, signal_std, "
"and max_mean_adjustment must be floats"
)
# check the Callable signature
if not all(
i in inspect.signature(adjustment_function).parameters
for i in (
"binding_enrichment_data",
"signal_mean",
"noise_mean",
"max_adjustment",
)
):
raise ValueError(
"adjustment_function must have the signature "
"(binding_enrichment_data, signal_mean, noise_mean, max_adjustment)"
)

signal_mask = (binding_data[:, :, 0] == 1).any(dim=1)

Expand Down

0 comments on commit d903331

Please sign in to comment.