From 9432aaf28963d8ffc122fdf597f914939ce2afff Mon Sep 17 00:00:00 2001
From: pswain <peter.swain@ed.ac.uk>
Date: Fri, 13 Jan 2023 11:48:58 +0000
Subject: [PATCH] final docs for postprocessor

---
 src/agora/io/decorators.py   |  8 ++++----
 src/agora/io/signal.py       | 19 +++++++++++++------
 src/postprocessor/chainer.py |  1 +
 src/postprocessor/grouper.py |  6 ++++--
 4 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/agora/io/decorators.py b/src/agora/io/decorators.py
index f0eea7e0..f4d8d023 100644
--- a/src/agora/io/decorators.py
+++ b/src/agora/io/decorators.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env jupyter
 """
-Convenience decorators that extend commonly-used methods or functions.
+Convenience decorators to extend commonly-used methods or functions.
 """
 import typing as t
 from functools import wraps
@@ -9,14 +9,14 @@ from functools import wraps
 def _first_arg_str_to_df(
     fn: t.Callable,
 ):
-    """Ensures Signal-like classes convert strings to datasets when calling them"""
-
+    """Enable Signal-like classes to convert strings to data sets."""
     @wraps(fn)
     def format_input(*args, **kwargs):
         cls = args[0]
         data = args[1]
         if isinstance(data, str):
+            # get data from h5 file
             data = cls.get_raw(data)
+        # replace path in the undecorated function with data
         return fn(cls, data, *args[2:], **kwargs)
-
     return format_input
diff --git a/src/agora/io/signal.py b/src/agora/io/signal.py
index 974fbfa5..165a7e03 100644
--- a/src/agora/io/signal.py
+++ b/src/agora/io/signal.py
@@ -42,7 +42,7 @@ class Signal(BridgeH5):
             "Cy5",
             "pHluorin405",
         )
-        # Alan: why  "equivalences"?
+        # Alan: why  "equivalences"? this variable is unused.
         equivalences = {
             "m5m": ("extraction/GFP/max/max5px", "extraction/GFP/max/median")
         }
@@ -118,7 +118,13 @@ class Signal(BridgeH5):
 
     @_first_arg_str_to_df
     def retained(self, signal, cutoff=0.8):
-        """Reduce a dataframe, or a list of dataframes, to a fraction of its former size, losing late time points."""
+        """
+        Load data (via decorator) and reduce the resulting dataframe.
+
+        Load data for a signal or a list of signals and reduce the resulting
+        dataframes to a fraction of their original size, losing late time
+        points.
+        """
         if isinstance(signal, pd.DataFrame):
             return self.get_retained(signal, cutoff)
         elif isinstance(signal, list):
@@ -144,6 +150,7 @@ class Signal(BridgeH5):
                     tile_mo_da["trap"],
                     tile_mo_da["mother_label"],
                     tile_mo_da["daughter_label"],
+                    a
                 )
             ).T
         return lineage
@@ -161,7 +168,7 @@ class Signal(BridgeH5):
         Parameters
         ----------
         data : t.Union[str, pd.DataFrame]
-            DataFrame or url to one.
+            DataFrame or path to one.
         merges : t.Union[np.ndarray, bool]
             (optional) 2-D array with three columns: the tile id, the mother label, and the daughter id.
             If True, fetch merges from file.
@@ -215,7 +222,7 @@ class Signal(BridgeH5):
         if not hasattr(self, "_available"):
             self._available = []
             with h5py.File(self.filename, "r") as f:
-                f.visititems(self.store_signal_url)
+                f.visititems(self.store_signal_path)
         for sig in self._available:
             print(sig)
 
@@ -231,7 +238,7 @@ class Signal(BridgeH5):
             if not hasattr(self, "_available"):
                 self._available = []
             with h5py.File(self.filename, "r") as f:
-                f.visititems(self.store_signal_url)
+                f.visititems(self.store_signal_path)
         except Exception as e:
             print("Error visiting h5: {}".format(e))
         return self._available
@@ -344,7 +351,7 @@ class Signal(BridgeH5):
         """Get name of h5 file."""
         return self.filename.stem
 
-    def store_signal_url(
+    def store_signal_path(
         self,
         fullname: str,
         node: t.Union[h5py.Dataset, h5py.Group],
diff --git a/src/postprocessor/chainer.py b/src/postprocessor/chainer.py
index ff3bce3e..a5387ccb 100644
--- a/src/postprocessor/chainer.py
+++ b/src/postprocessor/chainer.py
@@ -83,6 +83,7 @@ class Chainer(Signal):
         **kwargs,
     ):
         """Load data from an h5 file."""
+        1/0
         if dataset in self.common_chains:
             # get dataset for composite chains
             data = self.common_chains[dataset](**kwargs)
diff --git a/src/postprocessor/grouper.py b/src/postprocessor/grouper.py
index edde1805..0bcfd841 100644
--- a/src/postprocessor/grouper.py
+++ b/src/postprocessor/grouper.py
@@ -91,7 +91,8 @@ class Grouper(ABC):
         **kwargs,
     ):
         """
-        Concatenate data for one signal from different h5 files, with one h5 file per position, into a dataframe.
+        Concatenate data for one signal from different h5 files, with
+        one h5 file per position, into a dataframe.
 
         Parameters
         ----------
@@ -387,7 +388,7 @@ def concat_signal_ind(
     **kwargs,
 ) -> pd.DataFrame:
     """
-    Core function that retrieves an individual signal.
+    Retrieve an individual signal.
 
     Applies filtering if requested and adjusts indices.
     """
@@ -482,6 +483,7 @@ class MultiGrouper:
         return self._sigtable
 
     # Alan: function seems out of place
+    # seaborn is not in pyproject.toml
     def sigtable_plot(self) -> None:
         """
         Plot number of chains for all available experiments.
-- 
GitLab