Skip to content

Commit

Permalink
add fall-back to time-range filter if incorrect argument is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
fit-sebastiaan-van-zelst committed Jan 8, 2021
1 parent adfef25 commit 3c9441b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pm4py/filtering.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import deprecation

from pm4py import VERSION as PM4PY_CURRENT_VERSION
Expand Down Expand Up @@ -97,7 +99,8 @@ def filter_attribute_values(log, attribute_key, values, level="case", retain=Tru
attributes_filter.Parameters.POSITIVE: retain})
elif level == "case":
return attributes_filter.apply(log, values, parameters={
constants.PARAMETER_CONSTANT_ATTRIBUTE_KEY: attribute_key, attributes_filter.Parameters.POSITIVE: retain})
constants.PARAMETER_CONSTANT_ATTRIBUTE_KEY: attribute_key,
attributes_filter.Parameters.POSITIVE: retain})
else:
from pm4py.algo.filtering.log.attributes import attributes_filter
if level == "event":
Expand All @@ -106,7 +109,8 @@ def filter_attribute_values(log, attribute_key, values, level="case", retain=Tru
attributes_filter.Parameters.POSITIVE: retain})
else:
return attributes_filter.apply(log, values, parameters={
constants.PARAMETER_CONSTANT_ATTRIBUTE_KEY: attribute_key, attributes_filter.Parameters.POSITIVE: retain})
constants.PARAMETER_CONSTANT_ATTRIBUTE_KEY: attribute_key,
attributes_filter.Parameters.POSITIVE: retain})


def filter_trace_attribute(log, attribute_key, values, retain=True):
Expand Down Expand Up @@ -322,6 +326,9 @@ def filter_timestamp(log, dt1, dt2, mode="events"):
return timestamp_filter.filter_traces_contained(log, dt1, dt2)
elif mode == "traces_intersecting":
return timestamp_filter.filter_traces_intersecting(log, dt1, dt2)
else:
warnings.warn('mode provided: ' + mode + ' is not recognized; original log returned!')
return log
else:
from pm4py.algo.filtering.log.timestamp import timestamp_filter
if mode == "events":
Expand All @@ -330,3 +337,6 @@ def filter_timestamp(log, dt1, dt2, mode="events"):
return timestamp_filter.filter_traces_contained(log, dt1, dt2)
elif mode == "traces_intersecting":
return timestamp_filter.filter_traces_intersecting(log, dt1, dt2)
else:
warnings.warn('mode provided: ' + mode + ' is not recognized; original log returned!')
return log

0 comments on commit 3c9441b

Please sign in to comment.