Skip to content

Commit

Permalink
Issue firefly-cpp#201: Fix typos, make documentation more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaMi27 committed Dec 10, 2024
1 parent 8cbf8ec commit 0157cc1
Show file tree
Hide file tree
Showing 24 changed files with 230 additions and 190 deletions.
2 changes: 1 addition & 1 deletion docs/api/activity_generator.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Activity generator
Activity Generator
==================

.. automodule:: sport_activities_features.activity_generator
Expand Down
2 changes: 1 addition & 1 deletion docs/api/data_extraction_from_csv.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Data Extraction from csv files
Data Extraction from CSV Files
==============================

.. automodule:: sport_activities_features.data_extraction_from_csv
Expand Down
2 changes: 1 addition & 1 deletion docs/api/plot_data.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Plot data
Plot Data
=========

.. automodule:: sport_activities_features.plot_data
Expand Down
2 changes: 1 addition & 1 deletion docs/api/tcx_manipulation.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TCX manipulation
TCX Manipulation
================

.. automodule:: sport_activities_features.tcx_manipulation
Expand Down
2 changes: 1 addition & 1 deletion docs/api/topographic_features.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Topographic features
Topographic Features
====================

.. automodule:: sport_activities_features.topographic_features
Expand Down
2 changes: 1 addition & 1 deletion docs/api/training_loads.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Training loads
Training Loads
==============

.. automodule:: sport_activities_features.training_loads
Expand Down
4 changes: 2 additions & 2 deletions sport_activities_features/activity_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class SportyDataGen:
Brezočnik, L.,
Podgorelec, V.,
& Fister, I. (2018).
SportyDataGen: An Online Generator of Endurance
Sports Activity Collections.
SportyDataGen: An Online Generator of Endurance Sports Activity Collections.
In Central European Conference on Information
and Intelligent Systems (pp. 171-178).
Faculty of Organization and Informatics Varazdin.
Expand All @@ -21,6 +20,7 @@ class SportyDataGen:
[WIP]
This class is still under developement,
therefore its methods may not work as expected.
"""

def __init__(self, **kwargs) -> None:
Expand Down
27 changes: 14 additions & 13 deletions sport_activities_features/area_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AreaIdentification:
positions (np.array):
coordinates of positions as an array of latitudes and longitudes
distances (np.array):
cummulative distances as an array of floats
cumulative distances as an array of floats
timestamps (np.array):
information about time as an array of datetimes
heart_rates (np.array):
Expand Down Expand Up @@ -42,7 +42,7 @@ def __init__(
coordinates of positions as an array of latitudes
and longitudes
distances (np.array):
cummulative distances as an array of floats
cumulative distances as an array of floats
timestamps (np.array):
information about time as an array of datetimes
heart_rates (np.array):
Expand All @@ -58,8 +58,7 @@ def __init__(
self.area_coordinates = area_coordinates

def is_equal(self, value_1: float, value_2: float) -> bool:
"""Method for checking whether the two float values are equal
with certain tolerance (because of round error).\n
"""Method for checking whether the two float values are equal with certain tolerance (because of round error).\n
Args:
value_1 (float):
first value
Expand Down Expand Up @@ -99,7 +98,7 @@ def do_two_line_segments_intersect(
True if the two lines have an intersection point,
False otherwise.
"""
# Initialization of vectors and values.
# Initialisation of vectors and values.
v12 = np.array(p2 - p1)
v34 = np.array(p4 - p3)
v31 = np.array(p1 - p3)
Expand Down Expand Up @@ -169,14 +168,16 @@ def identify_points_in_area(self) -> None:

def extract_data_in_area(self) -> dict:
"""Method for extracting the data of the identified points in area.\n
Returns: area_data: {
'distance': distance,
'time': time,
'average_speed': average_speed,
'minimum_heart_rate': minimum_heart_rate,
'maximum_heart_rate': maximum_heart_rate,
'average_heart_rate': average_heart_rate
}.
Returns:
dict:
{
'distance': distance,
'time': time,
'average_speed': average_speed,
'minimum_heart_rate': minimum_heart_rate,
'maximum_heart_rate': maximum_heart_rate,
'average_heart_rate': average_heart_rate
}.
"""
distance = 0.0
time = 0.0
Expand Down
3 changes: 1 addition & 2 deletions sport_activities_features/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class StoredSegments:
average_slope():
Note:
----
Note:
[WIP]
This class is still under developement,
therefore its methods may not work as expected.
Expand Down
2 changes: 2 additions & 0 deletions sport_activities_features/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def load_pipeline(file_name: str) -> Pipeline:
Args:
file_name (str):
path to a binary pipeline file
Returns:
Pipeline: instance of Pipeline object from the NiaAML framework
Note:
See NiaAML's documentation for more details
on the use of the Pipeline class.
Expand Down
6 changes: 3 additions & 3 deletions sport_activities_features/data_extraction_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def __init__(self, activities: list = None) -> None:
"""
self.activities = activities

def from_file(self, path: str) -> list:
def from_file(self, path: str) -> pd.DataFrame:
"""Method for extracting data from CSV file to dataframe.\n
Args:
path (str): absolute path to the CSV file
Returns:
list: list of activities.
pandas.DataFrame: pandas DataFrame of activities.
"""
with open(
path + '.csv'
Expand All @@ -47,7 +47,7 @@ def from_all_files(self, path: str) -> list:
path (str):
absolute path to the folder with CSV files
Returns:
list: list of activities.
list: list of pandas DataFrames.
"""
if not path.endswith('/'):
path = path + '/'
Expand Down
39 changes: 18 additions & 21 deletions sport_activities_features/dead_end_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ class DeadEndIdentification:
positions (np.array):
array of positions as pairs of latitudes and longitudes
distances (np.array):
array of cummulative distances
array of cumulative distances
tolerance_degrees (float):
tolerance of driving the same route in
the opposite direction given in degrees
tolerance of driving the same route in the opposite direction given in degrees
tolerance_position (float):
tolerance of positions given in meters
minimum_distance (int):
minimum distance of a dead end
U_turn_allowed_distance (int):
maximum distance of a U-turn while
turning around and starting a dead end
maximum distance of a U-turn while turning around and starting a dead end
Note:
[WIP]
This class is still under developement, therefore
Expand All @@ -49,17 +47,15 @@ def __init__(
positions (np.array):
array of positions as pairs of latitudes and longitudes
distances (np.array):
array of cummulative distances
array of cumulative distances
tolerance_degrees (float):
tolerance of driving the same route in
the opposite direction given in degrees
tolerance of driving the same route in the opposite direction given in degrees
tolerance_position (float):
tolerance of positions given in meters
minimum_distance (int):
minimum distance of a dead end
U_turn_allowed_distance (int):
maximum distance of a U-turn while
turning around and starting a dead end.
maximum distance of a U-turn while turning around and starting a dead end.
"""
# Reorganizing the exercise data in order to achieve better results.
self.reorganize_exercise_data(
Expand All @@ -84,7 +80,7 @@ def reorganize_exercise_data(
positions (np.array):
array of positions as pairs of latitudes and longitudes
distances (np.array):
array of cummulative distances
array of cumulative distances
interval_distance (int):
desired distance between two neighboring points.
"""
Expand Down Expand Up @@ -143,8 +139,8 @@ def is_dead_end(
tolerance_azimuth (float):
difference tolerance of the two azimuths
Returns:
bool: True if given azimuths are within the given tolerance,
False otherwise.
bool:
True, if given azimuths are within the given tolerance, False otherwise.
"""
if abs(180 - abs(azimuth_1 - azimuth_2)) < tolerance_azimuth:
return True
Expand All @@ -159,11 +155,12 @@ def long_enough_to_be_a_dead_end(
long enough to be a dead end.\n
Args:
start_distance (float):
cummulative distance at the start of the dead end
cumulative distance at the start of the dead end
finish_distance (float):
cummulative distance at the end of the dead end
cumulative distance at the end of the dead end
Returns:
bool: True if dead end is long enough, False otherwise.
bool:
True, if dead end is long enough, False otherwise.
"""
if finish_distance - start_distance < self.minimum_distance:
return False
Expand All @@ -184,8 +181,8 @@ def really_is_dead_end(
tolerance_coordinates (float):
the tolerance between the two positions in meters
Returns:
bool: True if a track segment is a part of dead end,
False otherwise.
bool:
True, if a track segment is a part of dead end, False otherwise.
"""
print(geopy.distance.distance(position1, position2).m)
if (geopy.distance.distance(position1, position2).m
Expand Down Expand Up @@ -299,9 +296,9 @@ def draw_map(self) -> None:
def show_map(self) -> plt:
"""Method for plotting the exercise with dead ends.
Returns
-------
plt.
Returns:
plt (matplotlib.pyplot):
plot of the exercise with dead ends.
"""
if np.shape(self.positions)[0] == 0:
msg = 'Dataset is empty or invalid.'
Expand Down
37 changes: 18 additions & 19 deletions sport_activities_features/file_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ class FileManipulation:
def count_missing_values(self, list):
"""Counts the number of elements with value Nona.
Args:
----
Args:
list (list/ndarray): list to check
Returns:
(int): number of elements with value None in list.
int: number of elements with value None in list.
"""
count = 0
for i in list:
Expand All @@ -24,13 +23,14 @@ def count_missing_values(self, list):
return count

def __missing_from_to(self, lst, start):
"""Finds to which index the values are missing
"""Finds to which index the values are missing.
Args:
lst (list/ndarray): list on which to search
for consecutive missing values
start(int): index from where to search forward
lst (list/ndarray):
list on which to search for consecutive missing values
start(int):
index from where to search forward
Returns:
(int): ending index of consecutive missing values.
int: ending index of consecutive missing values.
"""
index = start
while index < len(lst):
Expand All @@ -44,8 +44,7 @@ def __set_value_type(self, baseline, value):
"""Private method that changes the value into
baseline type (chooses between int and float).
Args:
----
Args:
baseline: who to compare to
value: who to compare
Returns:
Expand All @@ -64,16 +63,16 @@ def linear_fill_missing_values(self, activity, key, max_seconds=15):
"""Function that lineary fills missing values, if the
successive missing values are up to (max_seconds) apart.
Args:
----
activity: TCXReader read file
key (str): dictionary key (e.g. 'heartrates', 'distances', ...)
max_seconds (int): maximum time between two valid values,
to still fill the missing values.
Args:
activity:
TCXReader read file
key (str):
dictionary key (e.g. 'heartrates', 'distances', ...)
max_seconds (int):
maximum time between two valid values, to still fill the missing values.
Returns:
-------
/ Transforms the sent array / list.
Returns:
Transformed sent array / list.
"""
index = 0
count = len(activity[key])
Expand Down
Loading

0 comments on commit 0157cc1

Please sign in to comment.