Skip to content

Commit

Permalink
fix anc_pop_id input
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-french committed May 2, 2024
1 parent 36170bb commit 281e35b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spaceprime/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def read_individuals(args, coords):


def read_anc_pop_id(anc_pop_id):
if anc_pop_id[0] is not None and not len(anc_pop_id) > 1:
if anc_pop_id is not None and not len(anc_pop_id) > 1:
if not os.path.exists(anc_pop_id[0]):
raise FileNotFoundError(f"anc_pop_id file {anc_pop_id[0]} not found")
else:
Expand Down
8 changes: 8 additions & 0 deletions spaceprime/demography.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Union, List, Optional
import msprime
from .utilities import calc_migration_matrix
import warnings


## not sure if I should add a subclass or not. There are only two new functions, so might not be worth it.
Expand Down Expand Up @@ -270,6 +271,13 @@ def add_ancestral_populations(
if not isinstance(anc_sizes, list):
anc_sizes = [anc_sizes]

# set anc_id to None and throw a warning if anc_sizes is less than 2
if len(anc_sizes) < 2 and anc_id is not None:
warnings.warn(
"anc_sizes is less than two, but you provided a list of anc_id's. If you meant to setup more than one anc_size, provide a list of sizes to anc_size. Otherwise, you're fine."
)
anc_id = None

# check merge time
if isinstance(merge_time, list):
raise ValueError("merge_time should be a single float or int, not a list.")
Expand Down

0 comments on commit 281e35b

Please sign in to comment.