From 09ad155f514a1513454af1089858dbb154f90beb Mon Sep 17 00:00:00 2001 From: "E. Joshua Rigler" <erigler@usgs.gov> Date: Mon, 1 Jun 2020 19:34:07 -0600 Subject: [PATCH] Pass unit tests again The first attempt to fix TimeseriesUtility.pad_and_trim_trace() broke a unit test. I'm not sure I agree with what the unit test defined as passing, but I do understand the logic. This now satisfies the logic of the unit test(s), while still fixing the floating point precision problem to the default resolution of UTCDateTime objects (that is, 1e-6 or microseconds) --- geomagio/TimeseriesUtility.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geomagio/TimeseriesUtility.py b/geomagio/TimeseriesUtility.py index 49997d2d..11d33515 100644 --- a/geomagio/TimeseriesUtility.py +++ b/geomagio/TimeseriesUtility.py @@ -514,7 +514,7 @@ def pad_and_trim_trace(trace, starttime, endtime): trace.stats.starttime = trace_starttime elif trace_starttime > starttime: # pad to starttime - cnt = round((trace_starttime - starttime) / trace_delta) + cnt = int(round((trace_starttime - starttime) / trace_delta, 6)) if cnt > 0: trace.data = numpy.concatenate( [numpy.full(cnt, numpy.nan, dtype=numpy.float64), trace.data] @@ -528,7 +528,7 @@ def pad_and_trim_trace(trace, starttime, endtime): trace.stats.npts = len(trace.data) elif trace_endtime < endtime: # pad to endtime - cnt = round((endtime - trace_endtime) / trace.stats.delta) + cnt = int(round((endtime - trace_endtime) / trace.stats.delta, 6)) if cnt > 0: trace.data = numpy.concatenate( [trace.data, numpy.full(cnt, numpy.nan, dtype=numpy.float64)] -- GitLab