Skip to content

Commit

Permalink
Handled Zero Division Error in pipeline.py (#344)
Browse files Browse the repository at this point in the history
* Handled Zero Division Error

* Apply suggestions from code review

Co-authored-by: Benedikt Mersch <[email protected]>

* Update pipeline.py 

updated pipeline.py based on @benemer  suggestions where the results are only appended when avg fps is greater than zero

* Fix formatting

---------

Co-authored-by: Benedikt Mersch <[email protected]>
Co-authored-by: tizianoGuadagnino <[email protected]>
  • Loading branch information
3 people authored Jul 10, 2024
1 parent 8596de8 commit 5d42087
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions python/kiss_icp/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ def _run_evaluation(self):
# Run timing metrics evaluation, always
def _get_fps():
total_time_s = sum(self.times) * 1e-9
return float(len(self.times) / total_time_s)

avg_fps = int(np.ceil(_get_fps()))
avg_ms = int(np.ceil(1e3 * (1 / _get_fps())))
self.results.append(desc="Average Frequency", units="Hz", value=avg_fps, trunc=True)
self.results.append(desc="Average Runtime", units="ms", value=avg_ms, trunc=True)
return float(len(self.times) / total_time_s) if total_time_s > 0 else 0

fps = _get_fps()
avg_fps = int(np.floor(fps))
avg_ms = int(np.ceil(1e3 / fps)) if fps > 0 else 0
if avg_fps > 0:
self.results.append(desc="Average Frequency", units="Hz", value=avg_fps, trunc=True)
self.results.append(desc="Average Runtime", units="ms", value=avg_ms, trunc=True)

def _write_log(self):
if not self.results.empty():
Expand Down

0 comments on commit 5d42087

Please sign in to comment.