Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

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])

Parameters

  • filter_names : List[str]
  • filters : List[Filter] -> Filter

Methods

Filtering

Use the filter() method to filter a list of WorkoutRoute. Only routes that were selected by the filters will be left.

Parameters:

Returns:

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)
Clone this wiki locally