Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Test pipeline error resolution #176

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions sport_activities_features/hill_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def identify_hills(self) -> None:
if abs(current_descent) >= self.ascent_threshold:
is_descent = True

if ((is_ascent and is_descent) and array_of_changes_indexes[i][2] < 0) or i == (len(array_of_changes_indexes) - 1):
if (((is_ascent and is_descent) and array_of_changes_indexes[i][2] < 0)
or i == (len(array_of_changes_indexes) - 1)):
hill_segment_grade = None

is_a_list = isinstance(
Expand All @@ -181,8 +182,8 @@ def identify_hills(self) -> None:
if is_a_list and len(self.distances) == len(
self.altitudes
):
end_distance = self.distances[array_of_changes_indexes[0][1]]
start_distance = self.distances[array_of_changes_indexes[0][0]]
end_distance = self.distances[array_of_changes_indexes[i][1]]
start_distance = self.distances[start_x]
hill_segment_distance = (
end_distance - start_distance
)
Expand All @@ -192,22 +193,16 @@ def identify_hills(self) -> None:

self.identified_hills.append(StoredSegments(
[start_x, array_of_changes_indexes[i][1]],
array_of_changes_indexes[i][2],
current_ascent,
hill_segment_grade,
))

print('hill_segment_grade', hill_segment_grade)
start_x = array_of_changes_indexes[i][1]
is_ascent = False
is_descent = False
current_ascent = 0
current_descent = 0

for i in range (len(self.identified_hills)):
print(self.identified_hills[i].segment)
print(self.identified_hills[i].ascent)
print(self.identified_hills[i].average_slope)

def return_hills(self) -> list:
"""
Method for returning identified hills.\n
Expand Down
12 changes: 11 additions & 1 deletion sport_activities_features/topographic_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ def distance_of_hills(self, positions: list) -> float:
total_distance = 0.0
for i in range(len(self.identified_hills)):
current = self.identified_hills[i]

index_range = []

start = current[0] + 1
if current[0] == 0:
start = 0

for index in range(start, current[1]):
index_range.append(index)

distance = 0.0
if len(positions) < 5:
total_distance = 0.0
else:
for _j in range(len(current) - 1):
for _j in range(len(index_range) - 1):
distance = distance + self.calculate_distance(
positions[i][0],
positions[i + 1][0],
Expand Down
9 changes: 3 additions & 6 deletions tests/test_hill_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,24 @@ def test_avg_ascent_correct(self):
places=1,
)

@pytest.mark.skip(reason="need manual verification")
def test_distance_of_hills_correct(self):
self.assertAlmostEqual(
self.top.distance_of_hills(self.activity["positions"]),
20.0,
40.1,
places=1,
)

@pytest.mark.skip(reason="need manual verification")
def test_share_of_hills_correct(self):
distance_hills = self.top.distance_of_hills(self.activity["positions"])
self.assertAlmostEqual(
self.top.share_of_hills(
distance_hills, self.activity["total_distance"]
),
0.17,
0.34,
places=2,
)

@pytest.mark.skip(reason="need manual verification")
def test_avg_grade_of_hill(self):
self.assertAlmostEqual(
self.hill.identified_hills[0].average_slope, 2.336246, 5
self.hill.identified_hills[0].average_slope, 1.554688, 5
)
Loading