This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
FilterPipeline
marcjulianschwarz edited this page Feb 23, 2022
·
3 revisions
class watchlib.filtering.FilterPipeline()
The FilterPipeline
can be used to chain multiple filters in a row. It works with every Filter:
from watchlib.filtering import FilterPipeline, CountryFilter, DiagonalBBoxFilter
cf = CountryFilter(CountryFilter.countries["Germany"])
dbbf = DiagonalBBoxFilter(10)
fp = FilterPipeline(filter_names=["cf", "tf"], filters=[cf, dbbf])
-
filter_names :
List[str]
-
filters :
List[Filter]
-> Filter
Use the filter()
method to filter a list of WorkoutRoute. Only routes that were selected by the filters
will be left.
Parameters:
-
routes
:List[WorkoutRoute]
-> WorkoutRoute
Returns:
-
List[WorkoutRoute]
→ WorkoutRoute
Usage:
routes
is a list of WorkoutRoute previously loaded using DataLoader or CacheHandler.
from watchlib.filtering import FilterPipeline, CountryFilter, DiagonalBBoxFilter
cf = CountryFilter(CountryFilter.countries["Germany"])
dbbf = DiagonalBBoxFilter(10)
fp = FilterPipeline(filter_names=["cf", "tf"], filters=[cf, dbbf])
filtered_routes = fp.filter(routes)
# len(filtered_routes) <= len(routes)