From cc84c443a7f0a3253a23f12761a18a3a6c185f75 Mon Sep 17 00:00:00 2001 From: Swainlab <peter.swain@ed.ac.uk> Date: Mon, 17 Jul 2023 14:33:34 +0100 Subject: [PATCH] more docs; fixed Pandas warning for merge --- src/agora/utils/merge.py | 2 +- src/postprocessor/core/reshapers/bud_metric.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/agora/utils/merge.py b/src/agora/utils/merge.py index 442bdf0e..b588871b 100644 --- a/src/agora/utils/merge.py +++ b/src/agora/utils/merge.py @@ -48,7 +48,7 @@ def apply_merges(data: pd.DataFrame, merges: np.ndarray): # TODO Use matrices to perform merges in batch # for efficiency if valid_merges.any(): - to_merge = data.loc[indices] + to_merge = data.loc[indices].copy() targets, sources = zip(*merges[valid_merges]) for source, target in zip(sources, targets): target = tuple(target) diff --git a/src/postprocessor/core/reshapers/bud_metric.py b/src/postprocessor/core/reshapers/bud_metric.py index b5c9ab2c..57c01069 100644 --- a/src/postprocessor/core/reshapers/bud_metric.py +++ b/src/postprocessor/core/reshapers/bud_metric.py @@ -78,7 +78,9 @@ class BudMetric(LineageProcess): else: md_index = md_index.droplevel("mother_label") if len(md_index) < len(signal): - print("Dropped cells before applying bud_metric") # TODO log + print( + f"Dropped {len(signal) - len(md_index)} cells before applying bud_metric" + ) # TODO log # restrict signal to the cells in md_index moving mother_label to do so signal = ( signal.reset_index("mother_label") @@ -90,7 +92,7 @@ class BudMetric(LineageProcess): daughter_df = signal.loc[mother_labels > 0] # join data for daughters with the same mother output_df = daughter_df.groupby(["trap", "mother_label"]).apply( - lambda x: _combine_daughter_tracks(x) + combine_daughter_tracks ) output_df.columns = signal.columns # daughter data is indexed by mothers, which themselves have no mothers @@ -101,7 +103,7 @@ class BudMetric(LineageProcess): return output_df -def _combine_daughter_tracks(tracks: pd.DataFrame): +def combine_daughter_tracks(tracks: pd.DataFrame): """ Combine multiple time series of daughter cells into one time series. -- GitLab