def test_relabel(): """ """ trajs = Trajectories(data.brownian_trajs_df()) trajs.columns = ['x', 'y', 'z', 'new_label', 't'] trajs.relabel(inplace=True) new_values = [ [1.933058243735795, -14.581064591435775, 11.603556633147544, 0.0], [-12.862215173899491, -2.8611502446443238, -2.2738941196781424, 0.0], [9.100887851132633, 2.837252570763561, 2.875753940450461, 0.0], [-9.253860446235523, 11.345550876585719, 22.118203258275745, 0.0] ] assert trajs.iloc[:4].values.tolist() == new_values trajs = Trajectories(data.brownian_trajs_df()) trajs.columns = ['x', 'y', 'z', 'new_label', 't'] trajs = trajs.relabel(inplace=False) new_values = [ [1.933058243735795, -14.581064591435775, 11.603556633147544, 0.0], [-12.862215173899491, -2.8611502446443238, -2.2738941196781424, 0.0], [9.100887851132633, 2.837252570763561, 2.875753940450461, 0.0], [-9.253860446235523, 11.345550876585719, 22.118203258275745, 0.0] ] assert trajs.iloc[:4].values.tolist() == new_values
def test_project(): trajs = Trajectories(data.directed_motion_trajs_df()) trajs.rename(columns={'true_label': 'new_label'}, inplace=True) trajs.relabel() trajs.project([0, 1], coords=['x', 'y'], keep_first_time=False, reference=None, inplace=True, progress=False) excepted = np.array([[0.27027431, 0.], [-0.27027431, 0.], [-0.25306519, 0.69683713], [0.04633664, 0.31722648]]) assert_array_almost_equal(excepted, trajs.loc[:, ['x_proj', 'y_proj']].values[:4]) trajs = trajs.project([0, 1], coords=['x', 'y'], keep_first_time=False, reference=None, inplace=False, progress=False) assert_array_almost_equal(excepted, trajs.loc[:, ['x_proj', 'y_proj']].values[:4]) assert_raises(ValueError, trajs.project, [0, 1], coords=['x', 'y', 'z', 't'])
def test_project(): trajs = Trajectories(data.directed_motion_trajs_df()) trajs.rename(columns={'true_label': 'new_label'}, inplace=True) trajs.relabel() trajs.project([0, 1], coords=['x', 'y'], keep_first_time=False, reference=None, inplace=True, progress=False) excepted = np.array([[ 0.27027431, 0. ], [-0.27027431, 0. ], [-0.25306519, 0.69683713], [ 0.04633664, 0.31722648]]) assert_array_almost_equal(excepted, trajs.loc[:,['x_proj', 'y_proj']].values[:4]) trajs = trajs.project([0, 1], coords=['x', 'y'], keep_first_time=False, reference=None, inplace=False, progress=False) assert_array_almost_equal(excepted, trajs.loc[:,['x_proj', 'y_proj']].values[:4]) assert_raises(ValueError, trajs.project, [0, 1], coords=['x', 'y', 'z', 't'])
def test_relabel(): """ """ trajs = Trajectories(data.brownian_trajs_df()) trajs.columns = ['x', 'y', 'z', 'new_label', 't'] trajs.relabel(inplace=True) new_values = [[1.933058243735795, -14.581064591435775, 11.603556633147544, 0.0], [-12.862215173899491, -2.8611502446443238, -2.2738941196781424, 0.0], [9.100887851132633, 2.837252570763561, 2.875753940450461, 0.0], [-9.253860446235523, 11.345550876585719, 22.118203258275745, 0.0]] assert trajs.iloc[:4].values.tolist() == new_values trajs = Trajectories(data.brownian_trajs_df()) trajs.columns = ['x', 'y', 'z', 'new_label', 't'] trajs = trajs.relabel(inplace=False) new_values = [[1.933058243735795, -14.581064591435775, 11.603556633147544, 0.0], [-12.862215173899491, -2.8611502446443238, -2.2738941196781424, 0.0], [9.100887851132633, 2.837252570763561, 2.875753940450461, 0.0], [-9.253860446235523, 11.345550876585719, 22.118203258275745, 0.0]] assert trajs.iloc[:4].values.tolist() == new_values