Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#74: Apply feedback for interval filtering #86

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading