Skip to content

Commit

Permalink
chore(docstring): added assertion errors to the docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Szyszkowski committed Feb 20, 2025
1 parent 09ebb63 commit cd09903
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/gentropy/dataset/l2g_features/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def is_protein_coding_feature_logic(
Returns:
DataFrame: Feature dataset, with 1 if the gene is protein-coding, 0 if not.
Raises:
AssertionError: when provided `genomic_window` is more or equal to 500kb.
"""
assert genomic_window <= 500_000, "Genomic window must be less than 500kb."
genes_in_window = (
Expand Down
3 changes: 3 additions & 0 deletions src/gentropy/dataset/pairwise_ld.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def __post_init__(self: PairwiseLD) -> None:
"""Validating the dataset upon creation.
- Besides the schema, a pairwise LD table is expected have rows being a square number.
Raises:
AssertionError: When the number of rows in the provided dataframe to construct the LD matrix is not even after applying square root.
"""
row_count = self.df.count()

Expand Down
7 changes: 5 additions & 2 deletions src/gentropy/dataset/variant_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,13 @@ def filter_by_variant(self: VariantIndex, df: DataFrame) -> VariantIndex:
"""Filter variant annotation dataset by a variant dataframe.
Args:
df (DataFrame): A dataframe of variants
df (DataFrame): A dataframe of variants.
Returns:
VariantIndex: A filtered variant annotation dataset
VariantIndex: A filtered variant annotation dataset.
Raises:
AssertionError: When the variant dataframe does not contain eiter `variantId` or `chromosome` column.
"""
join_columns = ["variantId", "chromosome"]

Expand Down
3 changes: 3 additions & 0 deletions src/gentropy/datasource/ensembl/vep_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ def _get_most_severe_transcript(
|{0.6, transcript3} |
+----------------------+
<BLANKLINE>
Raises:
AssertionError: When `transcript_column_name` is not a string.
"""
assert isinstance(
transcript_column_name, str
Expand Down
2 changes: 2 additions & 0 deletions src/gentropy/method/l2g/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def fit(
Raises:
ValueError: Train data not set, nothing to fit.
AssertionError: When x_train_size or y_train_size are not zero.
"""
if (
self.x_train is not None
Expand Down Expand Up @@ -180,6 +181,7 @@ def log_to_wandb(
Raises:
RuntimeError: If dependencies are not available.
AssertionError: When x_train_size or y_train_size are not zero.
"""
if (
self.x_train is None
Expand Down
3 changes: 3 additions & 0 deletions src/gentropy/method/susie_inf.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ def credible_set_qc(
Returns:
StudyLocus: Credible sets which pass filters and LD clumping.
Raises:
AssertionError: When running in clump mode, but no study study_index or ld_index or ld_min_r2 were provided.
"""
cred_sets.df = (
cred_sets.df.withColumn(
Expand Down
3 changes: 3 additions & 0 deletions src/gentropy/variant_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def __init__(
source_formats (list[str]): Format of the input dataset.
output_path (str): Output VCF file path.
partition_size (int): Approximate number of variants in each output partition.
Raises:
AssertionError: When the length of `source_paths` does not match the lenght of `source_formats`.
"""
assert len(source_formats) == len(
source_paths
Expand Down

0 comments on commit cd09903

Please sign in to comment.