Skip to content

Commit b0ec995

Browse files
authored
syntax updates
1 parent 9a3264a commit b0ec995

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

fishplotpy/data.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import warnings
44
from typing import List, Optional, Union, Sequence, Dict, Tuple
55

6-
# Default color palette from R version (reversed as in R code)
6+
# Default color palette
77
DEFAULT_COLORS = [
88
"#888888", "#EF0000", "#FF6000", "#FFCF00", "#50FFAF",
99
"#00DFFF", "#0070FF", "#0000FF", "#00008F"
10-
][::-1] # R version uses rev(), so match it
10+
][::-1] # to match rev() in R
1111

1212

1313
class FishPlotData:
@@ -266,7 +266,7 @@ def _set_defaults(self, timepoints, clone_labels, clone_annots):
266266

267267
def _fix_disappearing_clones(self):
268268
"""Replaces intermediate zeros with small values for continuity."""
269-
modified_fracs = self.frac_table.values.copy() # Work on numpy array for efficiency
269+
modified_fracs = self.frac_table.values.copy() # numpy array more efficient
270270

271271
for clone_idx in range(self.n_clones):
272272
row = modified_fracs[clone_idx, :]
@@ -359,8 +359,6 @@ def _validate_inputs(self):
359359
f"({parent_fraction:.2f}) at timepoint {time_idx} (value {self.timepoints[time_idx]})."
360360
)
361361

362-
# Label and annotation counts were already checked in _set_defaults
363-
364362
def _set_colors(self, colors: Optional[List[str]]):
365363
"""Sets and validates the color list for clones."""
366364
if colors is None:
@@ -496,7 +494,7 @@ def layout_clones(self, separate_independent_clones: bool = False):
496494
processed_parents.add(parent_1based)
497495

498496
children_mask = (self.parents == parent_1based)
499-
children_indices = np.where(children_mask)[0] # 0-based indices
497+
children_indices = np.where(children_mask)[0]
500498

501499
# Add children to the queue for processing later
502500
# Convert 0-based index to 1-based ID for queue
@@ -536,8 +534,8 @@ def layout_clones(self, separate_independent_clones: bool = False):
536534
else:
537535
spacing = 0 # No space if no active children or no inner space
538536
else:
539-
# If parent is absent at this timepoint, children cannot be plotted either
540-
# Their fractions should also be 0 due to validation, but enforce here.
537+
# if parent is absent at this timepoint, children cannot be plotted either
538+
# their fractions should also be 0 due to validation, but enforce here
541539
spacing = 0
542540
# Set children y values to NaN if parent is NaN
543541
for child_idx in children_indices:
@@ -546,7 +544,6 @@ def layout_clones(self, separate_independent_clones: bool = False):
546544
continue # Skip processing children if parent absent
547545

548546
# Layout children vertically
549-
# Sort children by index? R processes them in order. Assume input order is fine.
550547
for clone_idx in children_indices: # clone_idx is 0-based
551548
clone_fraction = self.frac_table.iloc[clone_idx, time_idx]
552549

@@ -564,14 +561,7 @@ def layout_clones(self, separate_independent_clones: bool = False):
564561
# Clone is absent (fraction is 0)
565562
ybtm_matrix[clone_idx, time_idx] = np.nan
566563
ytop_matrix[clone_idx, time_idx] = np.nan
567-
xpos_matrix[clone_idx, time_idx] = np.nan # Mark x as NaN too
568-
569-
# R's "smooth ending" logic:
570-
# If clone was present in the previous timepoint, add a point
571-
# just before this timepoint with the previous y-coordinates.
572-
# Requires careful handling of temporary points.
573-
# Deferring this precise logic for now to get core layout working.
574-
# It might be better handled during shape generation (spline/polygon).
564+
xpos_matrix[clone_idx, time_idx] = np.nan # mark x as NaN too
575565

576566
# --- Finalize Coordinates ---
577567
final_xpos = []
@@ -630,8 +620,3 @@ def __repr__(self):
630620
status = "Layout computed"
631621
return (f"<FishPlotData object with {self.n_clones} clones, "
632622
f"{self.n_timepoints} timepoints. {status}>")
633-
634-
# --- Placeholder for R's helper getNestLevel ---
635-
# This logic is integrated into _get_nest_level
636-
# def getNestLevel(self, x): # Equivalent R function
637-
# pass

0 commit comments

Comments
 (0)