From 5cf6da4620d23978e1d12751aee33feef2f654f4 Mon Sep 17 00:00:00 2001
From: pswain <peter.swain@ed.ac.uk>
Date: Tue, 23 May 2023 19:14:36 +0100
Subject: [PATCH] minor doc changes

---
 src/postprocessor/core/lineageprocess.py     | 10 ++---
 src/postprocessor/core/reshapers/buddings.py | 40 ++++++++------------
 2 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/src/postprocessor/core/lineageprocess.py b/src/postprocessor/core/lineageprocess.py
index b8e3e76b..c359df89 100644
--- a/src/postprocessor/core/lineageprocess.py
+++ b/src/postprocessor/core/lineageprocess.py
@@ -12,7 +12,7 @@ from postprocessor.core.abc import PostProcessABC
 
 
 class LineageProcessParameters(ParametersABC):
-    """Parameters."""
+    """Parameters - none are necessary."""
 
     _defaults = {}
 
@@ -21,7 +21,7 @@ class LineageProcess(PostProcessABC):
     """
     To analyse lineage data.
 
-    Currently bare bones, but extracts lineage information from a signal or a Cells object.
+    Currently bare bones, but extracts lineage information from a Signal or Cells object.
     """
 
     def __init__(self, parameters: LineageProcessParameters):
@@ -35,7 +35,7 @@ class LineageProcess(PostProcessABC):
         lineage: np.ndarray,
         *args,
     ):
-        """Implement method required by PostProcessABC."""
+        """Implement method required by PostProcessABC - undefined."""
         pass
 
     @classmethod
@@ -47,9 +47,9 @@ class LineageProcess(PostProcessABC):
         **kwargs,
     ):
         """
-        Override PostProcess.as_function classmethod.
+        Override PostProcesABC.as_function method.
 
-        Lineage functions require lineage information to be passed if run as functions.
+        Lineage functions require lineage information to be run as functions.
         """
         parameters = cls.default_parameters(**kwargs)
         return cls(parameters=parameters).run(
diff --git a/src/postprocessor/core/reshapers/buddings.py b/src/postprocessor/core/reshapers/buddings.py
index acdf0165..4398b947 100644
--- a/src/postprocessor/core/reshapers/buddings.py
+++ b/src/postprocessor/core/reshapers/buddings.py
@@ -13,16 +13,10 @@ from postprocessor.core.lineageprocess import (
 
 
 class buddingsParameters(LineageProcessParameters):
-    """Parameter class to obtain budding events.
-
-    Parameters
-    ----------
-    LineageProcessParameters : lineage_location
-        Location of lineage matrix to be used for calculations.
+    """
+    Parameter class to obtain budding events.
 
-    Examples
-    --------
-    FIXME: Add docs.
+    Define the location of lineage information in the h5 file.
 
     """
 
@@ -31,45 +25,44 @@ class buddingsParameters(LineageProcessParameters):
 
 class buddings(LineageProcess):
     """
-    Calculate buddings in a trap assuming one mother per trap
-    returns a pandas series with the buddings.
+    Calculate buddings in a trap assuming one mother per trap.
+
+    Return a pandas series with the buddings.
 
-    We define a budding event as the moment in which a bud was identified for
-    the first time, even if the bud is not considered one until later
-    in the experiment.
+    We define a budding event as when a bud is first identified.
+
+    This bud may not be considered a bud until later in the experiment.
     """
 
     def __init__(self, parameters: buddingsParameters):
+        """Initialise buddings."""
         super().__init__(parameters)
 
     def run(
         self, signal: pd.DataFrame, lineage: np.ndarray = None
     ) -> pd.DataFrame:
+        """TODO."""
         lineage = lineage or self.lineage
-
-        # Get time of first appearance for all cells
-        fvi = signal.apply(lambda x: x.first_valid_index(), axis=1)
-
-        # Select mother cells in a given dataset
+        # select traps and mother cells in a given signal
         traps_mothers: t.Dict[tuple, list] = {
             tuple(mo): [] for mo in lineage[:, :2] if tuple(mo) in signal.index
         }
         for trap, mother, daughter in lineage:
             if (trap, mother) in traps_mothers.keys():
                 traps_mothers[(trap, mother)].append(daughter)
-
         mothers = signal.loc[
             set(signal.index).intersection(traps_mothers.keys())
         ]
-        # Create a new dataframe with dimensions (n_mother_cells * n_timepoints)
+        # create a new dataframe with dimensions (n_mother_cells * n_timepoints)
         buddings = pd.DataFrame(
             np.zeros((mothers.shape[0], signal.shape[1])).astype(bool),
             index=mothers.index,
             columns=signal.columns,
         )
         buddings.columns.names = ["timepoint"]
-
-        # Fill the budding events
+        # get time of first appearance for every cell using Pandas
+        fvi = signal.apply(lambda x: x.first_valid_index(), axis=1)
+        # fill the budding events
         for mother_id, daughters in traps_mothers.items():
             daughters_idx = set(
                 fvi.loc[
@@ -82,5 +75,4 @@ class buddings(LineageProcess):
                 mother_id,
                 daughters_idx,
             ] = True
-
         return buddings
-- 
GitLab