We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 19e5efc commit 524472dCopy full SHA for 524472d
1 file changed
tests/anoph/test_snp_frq.py
@@ -123,9 +123,9 @@ def add_random_year(*, api):
123
# Only create the new column if it doesn't already exist.
124
# Otherwise we'll get multiple columns with different suffixes, e.g. 'random_year_x' and 'random_year_y'.
125
if "random_year" not in sample_metadata_df.columns:
126
- random_years_as_list = np.random.choice(
127
- range(1900, 2100), len(sample_metadata_df)
128
- )
+ # Avoid "ValueError: No cohorts available" by selecting only a few different years at random.
+ selected_years = random.sample(range(1900, 2100), 3)
+ random_years_as_list = np.random.choice(selected_years, len(sample_metadata_df))
129
random_years_as_period_index = pd.PeriodIndex(random_years_as_list, freq="Y")
130
extra_metadata_df = pd.DataFrame(
131
{
0 commit comments