def hour_mask(n_days, hours): start_time = datetime.datetime(2016, 1, 1) intervals = [] for day in range(n_days): start = start_time + datetime.timedelta(days=day, hours=hours) end = start + datetime.timedelta(hours=1) intervals.append([start, end]) return traces.Domain(intervals)
def eval_lineqs(phi, x): lineqs = phi.lineqs start = max(y.domain.start() for y in x.values()) end = min(y.domain.end() for y in x.values()) domain = traces.Domain(start, end) return {lineq: eval_lineq(lineq, x, domain) for lineq in lineqs}
def const_trace(x, start=0): return traces.TimeSeries([(start, x)], domain=traces.Domain(start, oo))
import traces import random import datetime from infinity import inf d = traces.Domain() #[1,3], [2,4]) d = traces.Domain(None) d = traces.Domain(-inf, inf) # d = traces.Domain(-inf, 0) d = traces.Domain(1, 2) d = traces.Domain([1, 2]) d = traces.Domain([1, 2], [3, 4]) d = traces.Domain([(1, 2), (3, 4)]) d = traces.Domain([(2, 5), (3, 4)]) # d = traces.Domain(datetime.datetime(2001, 2, 3), datetime.datetime(2002, 3, 4)) # d = traces.Domain(1) # d = traces.Domain(1, 2, 3) # d = traces.Domain([1, 2, 3]) # d = traces.Domain([(1, 2), (3, 4, 5)]) # d = traces.Domain([]) # d = traces.Domain([1, 2, (3, 4)]) # d = traces.Domain(2, 1) # d = traces.Domain(2, 2) # d = traces.Domain([(1, 2), (2, 2)]) dom1 = traces.Domain(1, 2) dom2 = traces.Domain(3, 4) print dom1.union(dom2) raise 'STOP'