Skip to content

Commit

Permalink
pivot and var_names incompatible in VariantFrequencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jbloom committed Sep 13, 2024
1 parent 20a16b6 commit bde1f64
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions evofr/data/variant_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bde1f64

Please sign in to comment.