From 513584f9692020cb2ffd67eb340e51f67a506ac1 Mon Sep 17 00:00:00 2001 From: Elizabeth Berrigan Date: Tue, 26 Mar 2024 20:52:52 -0700 Subject: [PATCH] Lint --- sleap_roots/points.py | 9 ++++++--- sleap_roots/trait_pipelines.py | 16 +++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sleap_roots/points.py b/sleap_roots/points.py index 2110988..479f564 100644 --- a/sleap_roots/points.py +++ b/sleap_roots/points.py @@ -501,8 +501,9 @@ def flatten_associated_points(associations: dict) -> dict: Args: associations: A dictionary where each key is an index of a primary root and each value - is a dictionary containing 'primary_points' as the points of the primary root - and 'lateral_points' as an array of lateral root points that are closest to that primary root. + is a dictionary containing 'primary_points' as the points of the primary root + and 'lateral_points' as an array of lateral root points that are closest to + that primary root. Returns: A dictionary with the same keys as associations. Each key corresponds to a flattened @@ -534,7 +535,9 @@ def flatten_associated_points(associations: dict) -> dict: def plot_root_associations(associations: dict): - """Plots the associations between primary and lateral roots, including the line + """Plots the associations between primary and lateral roots. + + Plots the associations between primary and lateral roots, including the line connecting the closest points between each lateral root and its closest primary root, and ensures the color map does not include red. Adds explanations in the legend and inverts the y-axis for image coordinate system. diff --git a/sleap_roots/trait_pipelines.py b/sleap_roots/trait_pipelines.py index 3951b68..d09136c 100644 --- a/sleap_roots/trait_pipelines.py +++ b/sleap_roots/trait_pipelines.py @@ -116,9 +116,18 @@ class NumpyArrayEncoder(json.JSONEncoder): - """Custom encoder for NumPy array types.""" + """Custom encoder for NumPy array types. + + This encoder is used to serialize NumPy arrays to JSON.""" def default(self, obj): + """Serialize NumPy arrays to lists. + + Args: + obj: The object to serialize. + + Returns: + A list representation of the NumPy array.""" if isinstance(obj, np.ndarray): return obj.tolist() # Let the base class default method raise the TypeError @@ -1975,10 +1984,7 @@ def get_initial_frame_traits(self, plant: Series, frame_idx: int) -> Dict[str, A @attrs.define class MultipleDicotPipeline(Pipeline): - """Pipeline for computing traits for multiple dicot plants. - - Attributes: - """ + """Pipeline for computing traits for multiple dicot plants.""" def define_traits(self) -> List[TraitDef]: """Define the trait computation pipeline for primary roots."""