def test_history_snapshots__check_we_can_ensure_the_number_of_all_0_snapshots_is_one(self): data = [[0., 0., 0.,], [1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],] df = pd.DataFrame(data, columns = ['c1', 'c2', 'c3']) result = history_snapshots(df, 3, ensure_zeroes=1) expected = array([[[0., 0., 0.,], [0., 0., 0.,], [0., 0., 0.,],], [[0., 0., 0.,], [0., 0., 0.,], [1., 0., 0.,],], [[0., 0., 0.,], [1., 0., 0.,], [0., 1., 0.,],], [[1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],], ], dtype=np.float32) # print("expected") # print(expected) # print("result") # print(result) assert_array_equal(result, expected)
def test_history_snapshots__truncates_history_if_requested(self): data = [[1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],] df = pd.DataFrame(data, columns = ['c1', 'c2', 'c3']) result = history_snapshots(df, 2) expected = array([[[0., 0., 0.,], [1., 0., 0.,],], [[1., 0., 0.,], [0., 1., 0.,],], [[0., 1., 0.,], [0., 0., 1.,],], ], dtype=np.float32) assert_array_equal(result, expected)
def test_history_snapshots__creates_the_number_of_desired_snapshots(self): data = [[1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],] df = pd.DataFrame(data, columns = ['c1', 'c2', 'c3']) result = history_snapshots(df, 3) expected = array([[[0., 0., 0.,], [0., 0., 0.,], [1., 0., 0.,],], [[0., 0., 0.,], [1., 0., 0.,], [0., 1., 0.,],], [[1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],], ], dtype=np.float32) assert_array_equal(result, expected)
def test_history_snapshots__snapshot_length_defaults_to_history_length(self): data = [[1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],] df = pd.DataFrame(data, columns = ['c1', 'c2', 'c3']) result = history_snapshots(df, 3) expected = array([[[0., 0., 0.,], [0., 0., 0.,], [1., 0., 0.,],], [[0., 0., 0.,], [1., 0., 0.,], [0., 1., 0.,],], [[1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],], ], dtype=np.float32) assert_array_equal(result, expected)
def test_history_snapshots__skips_all_0_snapshots_if_requested(self): data = [[0., 0., 0.,], [1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],] df = pd.DataFrame(data, columns = ['c1', 'c2', 'c3']) result = history_snapshots(df, 3, ensure_zeroes=0) expected = array([[[0., 0., 0.,], [0., 0., 0.,], [1., 0., 0.,],], [[0., 0., 0.,], [1., 0., 0.,], [0., 1., 0.,],], [[1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,],], ], dtype=np.float32) assert_array_equal(result, expected)