def test_front_hind_w_scrambled_order(self): f_h_df = pd.DataFrame({'X': [20, 30, 70], 'Y': [300, 60, 210], 'area': [50, 50, 50], 'frame': [10, 8, 9], 'print_numb': [3,4,5]}) f_h_df['is_kept'] = True f_h_df = self.hulls_df.append(f_h_df, ignore_index=True) combo_prints = create_combo_prints(f_h_df, 5, 600) assert np.array_equal(combo_prints.sort_values(['print_numb']).is_hind, [False, False, False, False, True])
def test_front_hind_simple(self): f_h_df = pd.DataFrame({'X': [20, 30, 70], 'Y': [300, 60, 210], 'area': [50, 50, 50], 'frame': [8,9,10], 'print_numb': [3,4,5]}) f_h_df['is_kept'] = True f_h_df = self.hulls_df.append(f_h_df, ignore_index=True) combo_prints = create_combo_prints(f_h_df, 5, 600) assert np.array_equal(combo_prints.is_hind, [False, False, False, True, True])
def test_real_example(self): #test a more realistic dataframe, taken from a real run #TODO: match combo_prints and hulls bc currently y is different c_df = pd.read_pickle('16-090 2 20161115 automated scoring hull (5).p') assign_print_numbers(c_df, 20) key = pd.read_csv('16-090 2 20161115 automated scoring combo df (13).csv') combo_prints = create_combo_prints(c_df, 20, 1920) combo_prints.sort_values('print_numb', inplace=True) assert np.array_equal(combo_prints.astype('int').values, key.loc[:, combo_prints.columns].values)
def test_left_right_simple(self): f_h_df = pd.DataFrame({'X': [20, 30, 70, 20, 10], 'Y': [300, 60, 210, 40, 60], 'area': [50, 50, 50,50,50], 'frame': [8,9,10,10,10], 'print_numb': [3,4,5,6,7]}) f_h_df['is_kept'] = True f_h_df = self.hulls_df.append(f_h_df, ignore_index=True) combo_prints = create_combo_prints(f_h_df, 5, 600) assert np.array_equal(combo_prints.sort_values(['print_numb']).is_right, [False, True, True, False, True, False, False])
def test_front_hind_same_frame_prints(self): f_h_df = pd.DataFrame({'X': [20, 30, 70, 20, 10], 'Y': [300, 60, 210, 40, 60], 'area': [50, 50, 50,50,50], 'frame': [8,9,10,10,10], 'print_numb': [3,4,5,6,7]}) f_h_df['is_kept'] = True f_h_df = self.hulls_df.append(f_h_df, ignore_index=True) combo_prints = create_combo_prints(f_h_df, 5, 600) self.assertEqual(combo_prints.is_hind[5], True) self.assertEqual(combo_prints.is_hind[6], True) self.assertEqual(combo_prints.is_hind[7], False) self.assertEqual(combo_prints.is_hind[4], True)
def test_left_right_correct(self): combo_prints = create_combo_prints(self.hulls_df, 5, 600) assert np.array_equal(combo_prints.is_right, [False, True])
def test_frame_range_correct(self): combo_prints = create_combo_prints(self.hulls_df, 5, 600) assert np.array_equal(combo_prints.first_frame, [1,5]) assert np.array_equal(combo_prints.last_frame, [3,7])
def test_info_is_from_hull_with_max_area(self): combo_prints = create_combo_prints(self.hulls_df, 5, 600) assert np.array_equal(combo_prints.max_area, [100, 300]) assert np.array_equal(combo_prints.frame_max_a, [1,6]) assert np.array_equal(combo_prints.X, [400, 44]) assert np.array_equal(combo_prints.Y, [40, 203])