Skip to content

Commit

Permalink
Merge pull request #86 from amosproj/#74-Apply-feedback-for-interval-…
Browse files Browse the repository at this point in the history
…filtering

#74: Apply feedback for interval filtering
  • Loading branch information
FelipeTrost authored Dec 1, 2024
2 parents e1aeafa + e4df710 commit fe1c0e8
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def filter(self) -> DataFrame:
current_row = rows[i]
current_time_stamp = current_row[self.time_stamp_column_name]

if self.check_if_outside_of_interval(
if self.check_outside_of_interval(
current_time_stamp, last_time_stamp, time_delta_in_ms, tolerance_in_ms
):
current_row_dict = current_row.asDict()
Expand Down Expand Up @@ -167,21 +167,17 @@ def get_time_delta(self, value: int) -> timedelta:
"interval_unit must be either 'days', 'hours', 'minutes', 'seconds' or 'milliseconds'"
)

def check_if_outside_of_interval(
def check_outside_of_interval(
self,
current_time_stamp: pd.Timestamp,
last_time_stamp: pd.Timestamp,
time_delta_in_ms: float,
tolerance_in_ms: float,
) -> bool:
if tolerance_in_ms is None:
return (
(current_time_stamp - last_time_stamp).total_seconds() * 1000
) >= time_delta_in_ms
else:
return (
(current_time_stamp - last_time_stamp).total_seconds() * 1000
) + tolerance_in_ms >= time_delta_in_ms
time_difference = (current_time_stamp - last_time_stamp).total_seconds() * 1000
if not tolerance_in_ms is None:
time_difference += tolerance_in_ms
return time_difference >= time_delta_in_ms

def format_date_time_to_string(self, time_stamp: pd.Timestamp) -> str:
try:
Expand Down

0 comments on commit fe1c0e8

Please sign in to comment.