Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
eberrigan committed Mar 27, 2024
1 parent 77dd182 commit 513584f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 6 additions & 3 deletions sleap_roots/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 11 additions & 5 deletions sleap_roots/trait_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Check warning on line 132 in sleap_roots/trait_pipelines.py

View check run for this annotation

Codecov / codecov/patch

sleap_roots/trait_pipelines.py#L131-L132

Added lines #L131 - L132 were not covered by tests
# Let the base class default method raise the TypeError
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 513584f

Please sign in to comment.