From 75fa96b8f5fda4bb1f4b60a3ffb856962c852f88 Mon Sep 17 00:00:00 2001 From: Bruce Flynn <brucef@ssec.wisc.edu> Date: Tue, 16 Jan 2018 20:35:13 -0600 Subject: [PATCH] fix failing rdrgen tests --- edosl0util/merge.py | 7 +++---- edosl0util/timecode.py | 5 ++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/edosl0util/merge.py b/edosl0util/merge.py index d2951b5..b41dc0c 100644 --- a/edosl0util/merge.py +++ b/edosl0util/merge.py @@ -49,10 +49,9 @@ class _Ptr(object): def __lt__(self, that): return (self.stamp, self.apid) < (that.stamp, that.apid) - # WTF? - # instances with same timecode/apid/size will compare the same - # def __hash__(self): - # return hash((self.stamp, self.apid, self.size)) + # hash by stamp, apid, size so we can dedup in index using set + def __hash__(self): + return hash((self.stamp, self.apid, self.size)) def bytes(self): self.fobj.seek(self.offset, os.SEEK_SET) diff --git a/edosl0util/timecode.py b/edosl0util/timecode.py index 8c2c54f..d6160fd 100644 --- a/edosl0util/timecode.py +++ b/edosl0util/timecode.py @@ -30,7 +30,9 @@ def timecode_parts_to_iet(days, ms, us, epoch): Convert components to a IET based on arbitrary epoch. """ return int(_grain.utc2tai( - epoch + timedelta(days=days, milliseconds=ms, microseconds=us), + epoch + timedelta(days=float(days), + milliseconds=float(ms), + microseconds=float(us)), epoch) * 1e6) @@ -56,4 +58,5 @@ def dt_to_cds(dt): return (d.days, int(d.seconds * 1e3), d.microseconds) +dt_to_iet = _grain.utc2iet iet_to_dt = _grain.iet2utc -- GitLab