Skip to content

Commit cf08d9f

Browse files
CjkjvfnbyCaedenPH
andauthored
Format docs (TheAlgorithms#7821)
* Reformat docs for odd_even_sort.py * Fix docstring formatting * Apply suggestions from code review Co-authored-by: Caeden Perelli-Harris <[email protected]> Co-authored-by: Caeden Perelli-Harris <[email protected]>
1 parent 762afc0 commit cf08d9f

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

machine_learning/data_transformations.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""
2-
Normalization Wikipedia: https://en.wikipedia.org/wiki/Normalization
2+
Normalization.
3+
4+
Wikipedia: https://en.wikipedia.org/wiki/Normalization
35
Normalization is the process of converting numerical data to a standard range of values.
46
This range is typically between [0, 1] or [-1, 1]. The equation for normalization is
57
x_norm = (x - x_min)/(x_max - x_min) where x_norm is the normalized value, x is the
@@ -28,7 +30,8 @@
2830

2931
def normalization(data: list, ndigits: int = 3) -> list:
3032
"""
31-
Returns a normalized list of values
33+
Return a normalized list of values.
34+
3235
@params: data, a list of values to normalize
3336
@returns: a list of normalized values (rounded to ndigits decimal places)
3437
@examples:
@@ -46,7 +49,8 @@ def normalization(data: list, ndigits: int = 3) -> list:
4649

4750
def standardization(data: list, ndigits: int = 3) -> list:
4851
"""
49-
Returns a standardized list of values
52+
Return a standardized list of values.
53+
5054
@params: data, a list of values to standardize
5155
@returns: a list of standardized values (rounded to ndigits decimal places)
5256
@examples:

physics/kinetic_energy.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
2-
Find the kinetic energy of an object, give its mass and velocity
2+
Find the kinetic energy of an object, given its mass and velocity.
3+
34
Description : In physics, the kinetic energy of an object is the energy that it
45
possesses due to its motion. It is defined as the work needed to accelerate a body of a
56
given mass from rest to its stated velocity. Having gained this energy during its
@@ -19,6 +20,8 @@
1920

2021
def kinetic_energy(mass: float, velocity: float) -> float:
2122
"""
23+
Calculate kinetick energy.
24+
2225
The kinetic energy of a non-rotating object of mass m traveling at a speed v is ½mv²
2326
2427
>>> kinetic_energy(10,10)

sorts/merge_sort.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
2-
This is a pure Python implementation of the merge sort algorithm
2+
This is a pure Python implementation of the merge sort algorithm.
3+
34
For doctests run following command:
45
python -m doctest -v merge_sort.py
56
or
@@ -10,7 +11,7 @@
1011

1112

1213
def merge_sort(collection: list) -> list:
13-
"""Pure implementation of the merge sort algorithm in Python
14+
"""
1415
:param collection: some mutable ordered collection with heterogeneous
1516
comparable items inside
1617
:return: the same collection ordered by ascending
@@ -24,7 +25,9 @@ def merge_sort(collection: list) -> list:
2425
"""
2526

2627
def merge(left: list, right: list) -> list:
27-
"""merge left and right
28+
"""
29+
Merge left and right.
30+
2831
:param left: left collection
2932
:param right: right collection
3033
:return: merge result

sorts/odd_even_sort.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
"""For reference
1+
"""
2+
Odd even sort implementation.
3+
24
https://en.wikipedia.org/wiki/Odd%E2%80%93even_sort
35
"""
46

57

68
def odd_even_sort(input_list: list) -> list:
7-
"""this algorithm uses the same idea of bubblesort,
9+
"""
10+
Sort input with odd even sort.
11+
12+
This algorithm uses the same idea of bubblesort,
813
but by first dividing in two phase (odd and even).
914
Originally developed for use on parallel processors
1015
with local interconnections.

0 commit comments

Comments
 (0)