ITADN

filter: ambiguity in date ranges is not properly handled

#2007Openvictorlin 创建于 2026-06-02
bug
V
victorlincommented
### Current Behavior `augur filter` does not properly handle date ranges when grouping by generated date columns (`year`, `month`, `week`). For example, with `--group-by year`, a date of `2010-01-01/2011-12-31`, is not dropped by `--exclude-ambiguous-dates-by year`. The same issue applies to `month` and `week`. ### Expected behavior `augur filter` should support date ranges when grouping by generated date columns. For example, with `--group-by year`, a date of `2010-01-01/2011-12-31` should be treated as having an ambiguous `year`. Date ranges with exact parts should still be usable: - `2010-01-01/2010-12-31` has an exact `year`, but ambiguous `month` and `week` - `2010-01-01/2010-01-31` has an exact `year` and `month`, but ambiguous `week` - `2010-01-01/2010-01-01` has an exact `year`, `month`, and `week` ### How to reproduce Metadata file: ```tsv strain date location SEQ1 2010-01-01 A SEQ2 2010-01-01/2011-12-31 A SEQ3 2010-03-01 B ``` Command: ```sh augur filter \ --metadata metadata.tsv \ --group-by year location \ --subsample-max-sequences 1 \ --subsample-seed 0 \ --output-strains filtered-strains.txt ``` Error: ``` Sampling probabilistically at 0.3333 sequences per group, meaning it is possible to have more than the requested maximum of 1 sequences after filtering. Traceback (most recent call last): File "…/augur/filter/_run.py", line 333, in run group_sizes = get_probabilistic_group_sizes( File "…/augur/filter/subsample.py", line 297, in get_probabilistic_group_sizes for group in sorted(groups): File "pandas/_libs/missing.pyx", line …, in pandas._libs.missing.NAType.__bool__ TypeError: boolean value of NA is ambiguous An error occurred (see above) that has not been properly handled by Augur. ``` ### Possible solution Handle date ranges in `is_date_ambiguous()` instead of only determining ambiguity by presence of `X`. It could use `get_year_month_day()`.
0 条评论