Skip to content

Commit

Permalink
Merge pull request #146 from monarch-initiative/Row_Filter_Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinschaper authored Aug 20, 2024
2 parents 6371bfc + e8faf20 commit d99162e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/koza/utils/row_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, filters: List[ColumnFilter] = None):
'eq': eq,
'ne': ne,
'in': self.inlist, # not using operator.contains because the it expects opposite argument order
'in_exact': self.inlist_exact, # not using operator.contains because the it expects opposite argument order
}

def include_row(self, row) -> bool:
Expand Down Expand Up @@ -52,5 +53,24 @@ def include_row(self, row) -> bool:

return include_row

def inlist(self, column_value, filter_value):
return column_value in filter_value
def inlist(self, column_value, filter_values):
print('FILTER VALUES',filter_values)
#Check if the passed in column is exactly matched against
#For a filter_list of ['abc','def','ghi']; this will be true
#for column_value 'abc' but not 'abcde.'
col_exact_match = column_value in filter_values
#The following iterates through all filters and will return true if
#the text of the filter is found within the column_value.
#So for the above example this boolean will return True, because :'abc' in 'abcde': returns True.
if(type(column_value)==str):
col_inexact_match = any([filter_value in column_value for filter_value in filter_values])
else:
col_inexact_match = False
return col_exact_match or col_inexact_match

def inlist_exact(self, column_value, filter_values):
#Check if the passed in column is exactly matched against
#For a filter_list of ['abc','def','ghi']; this will be true
#for column_value 'abc' but not 'abcde.'
col_exact_match = column_value in filter_values
return col_exact_match

0 comments on commit d99162e

Please sign in to comment.