From bde1f64a3915efc3693f8a59635899ff415bfd5a Mon Sep 17 00:00:00 2001 From: jbloom Date: Fri, 13 Sep 2024 06:06:29 -0700 Subject: [PATCH 1/2] `pivot` and `var_names` incompatible in `VariantFrequencies` Previously you could specify both `pivot` and `var_names` when instantiating `VariantFrequencies`. But if this was done, the value of `pivot` was silently ignored in favor of making the pivot variant the last name in `var_names`. This pull request fixes this misleading behavior by making those parameters mutually exclusive, and raising an error if the user tries to set both. --- evofr/data/variant_frequencies.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/evofr/data/variant_frequencies.py b/evofr/data/variant_frequencies.py index 2082f3b..6a7cd22 100644 --- a/evofr/data/variant_frequencies.py +++ b/evofr/data/variant_frequencies.py @@ -80,16 +80,20 @@ def __init__( var_names: optional list containing names of variants to be present. + The last of these variants is used as the pivot. pivot: optional name of variant to place last. Defaults to "other" if present otherwise. This will usually used as a reference or pivot strain. + Can only be used if you do not set `var_names`. Returns ------- VariantFrequencies """ + if (pivot is not None) and (var_name is not None): + raise ValueError("cannot set both pivot and var_name") # Get mapping from date to index if date_to_index is None: From ae469e1309cd0eea1ca745358cf3a5d263c33c9d Mon Sep 17 00:00:00 2001 From: jbloom Date: Fri, 13 Sep 2024 06:23:25 -0700 Subject: [PATCH 2/2] fix typo in code change --- evofr/data/variant_frequencies.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evofr/data/variant_frequencies.py b/evofr/data/variant_frequencies.py index 6a7cd22..380bfdb 100644 --- a/evofr/data/variant_frequencies.py +++ b/evofr/data/variant_frequencies.py @@ -92,8 +92,8 @@ def __init__( ------- VariantFrequencies """ - if (pivot is not None) and (var_name is not None): - raise ValueError("cannot set both pivot and var_name") + if (pivot is not None) and (var_names is not None): + raise ValueError("cannot set both pivot and var_names") # Get mapping from date to index if date_to_index is None: