def data3(): # Distances between points is 2, 1, 3 # Time between points is (hours) 1, 3, 2 k = knox.Knox() times = [datetime.datetime(2016,1,1,1), datetime.datetime(2016,1,1,2), datetime.datetime(2016,1,1,4)] k.data = data.TimedPoints.from_coords(times, [1,1,1], [5, 7, 4]) return k
def data2(): # Distances between points is 1, sqrt(2), 1 # Time between points is (days) 1, 2, 1 k = knox.Knox() times = [datetime.datetime(2016,1,1), datetime.datetime(2016,1,2), datetime.datetime(2016,1,3)] k.data = data.TimedPoints.from_coords(times, [1,2,2], [5,5,6]) return k
def test_Knox_time_bins_set(): k = knox.Knox() k.set_time_bins([[1,2], [4,6]], unit="minutes") assert(len(k.time_bins) == 2) assert(k.time_bins[0][0] / np.timedelta64(1,"s") == 60.0) assert(k.time_bins[0][1] / np.timedelta64(1,"s") == 120.0) assert(k.time_bins[1][0] / np.timedelta64(1,"m") == 4.0) assert(k.time_bins[1][1] / np.timedelta64(1,"m") == 6.0)
def test_Knox_time_bins(): k = knox.Knox() td = datetime.timedelta k.time_bins = [[td(days=1), td(days=2)], [td(hours=1), td(hours=5)]] assert(len(k.time_bins) == 2) assert(k.time_bins[0][0] / np.timedelta64(1,"D") == 1.0) assert(k.time_bins[0][1] / np.timedelta64(1,"D") == 2.0) assert(k.time_bins[1][0] / np.timedelta64(1,"m") == 60.0) assert(k.time_bins[1][1] / np.timedelta64(1,"m") == 300.0)
def data1(): k = knox.Knox() times = [datetime.datetime(2016,1,1), datetime.datetime(2016,1,3)] k.data = data.TimedPoints.from_coords(times, [1,2], [5,5]) return k
def test_Knox_space_bins(): k = knox.Knox() k.space_bins = [[1,2], (4,5), [-1,5]] np.testing.assert_allclose(k.space_bins, [[1,2],[4,5],[-1,5]])