Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
eberrigan committed Oct 29, 2024
1 parent db0db11 commit 8854f02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
22 changes: 16 additions & 6 deletions tests/test_convhull.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pytest
import logging

from sleap_roots import Series
from sleap_roots.convhull import (
Expand Down Expand Up @@ -38,7 +39,9 @@ def valid_input():

@pytest.fixture
def invalid_input_with_inf_values():
pts = np.array([[[0, 0], [2, 2], [4, 0], [2, -2], [0, -4], [4, -4], [np.inf, np.inf]]])
pts = np.array(
[[[0, 0], [2, 2], [4, 0], [2, -2], [0, -4], [4, -4], [np.inf, np.inf]]]
)
return pts


Expand Down Expand Up @@ -134,7 +137,6 @@ def lateral_pts():
)



# test get_convhull with invalid input with inf values
def test_infinite_values_logging(invalid_input_with_inf_values, caplog):
with caplog.at_level(logging.INFO): # This message is INFO level
Expand Down Expand Up @@ -228,15 +230,23 @@ def test_get_convhull_features_rice(rice_h5, rice_long_slp, rice_main_slp):
max_height = get_chull_max_height(convex_hull)

# Get the intersection vectors
left_vector = get_chull_intersection_vectors_left(get_chull_intersection_vectors(r0_pts, r1_pts, crown_pts, convex_hull))
right_vector = get_chull_intersection_vectors_right(get_chull_intersection_vectors(r0_pts, r1_pts, crown_pts, convex_hull))
left_vector = get_chull_intersection_vectors_left(
get_chull_intersection_vectors(r0_pts, r1_pts, crown_pts, convex_hull)
)
right_vector = get_chull_intersection_vectors_right(
get_chull_intersection_vectors(r0_pts, r1_pts, crown_pts, convex_hull)
)
# Get angles from gravity
left_angle = get_vector_angles_from_gravity(left_vector)
right_angle = get_vector_angles_from_gravity(right_vector)

# Get the intersection areas
area_above = get_chull_area_via_intersection_above(get_chull_areas_via_intersection(r1_pts, crown_pts, convex_hull))
area_below = get_chull_area_via_intersection_below(get_chull_areas_via_intersection(r1_pts, crown_pts, convex_hull))
area_above = get_chull_area_via_intersection_above(
get_chull_areas_via_intersection(r1_pts, crown_pts, convex_hull)
)
area_below = get_chull_area_via_intersection_below(
get_chull_areas_via_intersection(r1_pts, crown_pts, convex_hull)
)

assert left_vector.shape == (1, 2)
assert right_vector.shape == (1, 2)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,10 @@ def test_extract_from_multilinestring(geometry, expected):
(np.array([1, 2]), []),
((), []),
([], []),
(MultiLineString([[(np.nan, np.nan), (1, 1)]]), []), # MultiLineString with invalid coordinates
(
MultiLineString([[(np.nan, np.nan), (1, 1)]]),
[],
), # MultiLineString with invalid coordinates
],
)
def test_extract_from_unsupported_geometry(unexpected_input, expected_output):
Expand Down

0 comments on commit 8854f02

Please sign in to comment.