Skip to content

Commit 9b7d6cc

Browse files
committed
Amend sample_metadata to allow sample_indices when surveillance_use_only
1 parent d9ba5eb commit 9b7d6cc

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

malariagen_data/anoph/sample_metadata.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ def sample_metadata(
773773
for on, data in self._extra_metadata:
774774
df_samples = df_samples.merge(data, how="left", on=on)
775775

776-
# Apply the sample_query or sample_indices, if specified.
776+
# Apply the sample_query, if there is one.
777+
# Note: this might have been internally modified, e.g. `is_surveillance == True`.
777778
if prepared_sample_query is not None:
778779
# Assume a pandas query string.
779780
sample_query_options = sample_query_options or {}
@@ -782,7 +783,10 @@ def sample_metadata(
782783
prepared_sample_query, **sample_query_options, engine="python"
783784
)
784785
df_samples = df_samples.reset_index(drop=True)
785-
elif sample_indices is not None:
786+
787+
# Apply the sample_indices, if there are any.
788+
# Note: this might need to apply to the result of an internal sample_query, e.g. `is_surveillance == True`.
789+
if sample_indices is not None:
786790
# Assume it is an indexer.
787791
df_samples = df_samples.iloc[sample_indices]
788792
df_samples = df_samples.reset_index(drop=True)

0 commit comments

Comments
 (0)