How do you use an empty set as a filter condition?

I would like to extract variants from a matrix table which have an empty filter field.

The type of this field is set.

If I extract filter elements with mt.row.filter.take(100) my first empty filter occurs at position 97.
If I check mt.row.filter.take(100)[97] == set() I get True so I hoped the following query would work:

my_new_table = mt.filter_rows(mt.row.filters==set())

It returns an error though:

hail.expr.expressions.base_expression.ExpressionException: cannot impute array elements

I’ve tried a few other expressions I hoped would represent an empty set but I’m not confident with the syntax. I can see documentation about empty sets on the API but it’s over my head.

Does anyone have a way to get extract these empty filters?

Thanks for any help you can provide!
Angus

1 Like

Replace set() with hl.empty_set(mt.row.filter.dtype.element_type). Hail needs to know what type of elements a container contains. It is annoying. It is what is is though. I generally use hl.len(mt.row.filters) == 0 for this reason.

Thank you very much for the speedy response - works perfectly!