Skip to content
Snippets Groups Projects
Commit 417e17a4 authored by Arin Wongprommoon's avatar Arin Wongprommoon
Browse files

[WIP] fix(postproc): separate variables for traps, mothers, daughters

WHY IS THIS CHANGE NEEDED?:
- IndexError raised when processor is invoked

HOW DOES THE CHANGE SOLVE THE PROBLEM?:
- multii variable (line 208) assumes that daughters is a 2d numpy array
  with at least 2 columns.  this is wrong, both mothers & daughters are
  lists.
- bug uncovers poor handling of variables that store info on traps,
  mothers, and daughters, so refactored them too.  specifically, the
  mothers variables stored traps AND mothers information -- now i've
  separated them.
- this also means that numpy.append makes no sense and i use
  numpy.column_stack() instead.

WHAT SIDE EFFECTS DOES THIS CHANGE HAVE?:
- tech debt: potentially more refactoring along the line in this file --
  the logic is quite convoluted.

EVIDENCE THAT COMMIT WORKS:
- yet to see

REFERENCES:
- issue #37
parent 2103179a
No related branches found
No related tags found
No related merge requests found
...@@ -201,13 +201,15 @@ class PostProcessor(ProcessABC): ...@@ -201,13 +201,15 @@ class PostProcessor(ProcessABC):
self._signal[self.targets["prepost"]["picker"][0]] self._signal[self.targets["prepost"]["picker"][0]]
) )
mothers, daughters = np.array(self.picker.mothers), np.array( # picker.mothers and picker.daughters already assigned based on
self.picker.daughters # picker.cells.mothers_daughters, but there is no picker.traps variable
) traps = self.cells.mothers_daughters[:, 0].tolist()
mothers = np.array(self.picker.mothers)
daughters = np.array(self.picker.daughters)
multii = pd.MultiIndex.from_arrays( multii = pd.MultiIndex.from_arrays(
( (
np.append(mothers, daughters[:, 1].reshape(-1, 1), axis=1).T np.column_stack((traps, mothers, daughters))
if daughters.any() if daughters.any()
else [[], [], []] else [[], [], []]
), ),
...@@ -257,7 +259,7 @@ class PostProcessor(ProcessABC): ...@@ -257,7 +259,7 @@ class PostProcessor(ProcessABC):
self.lineage_merged = pd.MultiIndex.from_arrays( self.lineage_merged = pd.MultiIndex.from_arrays(
np.unique( np.unique(
np.append(mothers, daughters[:, 1].reshape(-1, 1), axis=1), np.column_stack((traps, mothers, daughters)),
axis=0, axis=0,
).T, ).T,
names=["trap", "mother_label", "daughter_label"], names=["trap", "mother_label", "daughter_label"],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment