Skip to content

Commit

Permalink
filter: Add another test for numerical queries
Browse files Browse the repository at this point in the history
The existing test was good for comparisons between columns and numerical
constants, but did not cover comparisons between two numerical columns.
  • Loading branch information
victorlin committed Jan 24, 2024
1 parent 8161060 commit 696517d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/functional/filter/cram/filter-query-numerical.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,28 @@ The 'category' column will fail when used with a numerical comparison.
'>=' not supported between instances of 'str' and 'float'
Ensure the syntax is valid per <https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#indexing-query>.
[2]

Create another metadata file for testing.

$ cat >metadata.tsv <<~~
> strain metric1 metric2
> SEQ1 4 5
> SEQ2 5 9
> SEQ3 6 10
> ~~

Use a Pandas query to filter by a numerical value.
This relies on having proper data types associated with the columns. If < is
comparing strings, it's likely that SEQ3 will be dropped or errors arise.

$ ${AUGUR} filter \
> --metadata metadata.tsv \
> --query "metric1 > 4 & metric1 < metric2" \
> --output-strains filtered_strains.txt
1 strains were dropped during filtering
\t1 of these were filtered out by the query: "metric1 > 4 & metric1 < metric2" (esc)
2 strains passed all filters

$ sort filtered_strains.txt
SEQ2
SEQ3

0 comments on commit 696517d

Please sign in to comment.