From 230f133c881b0bba97c5f176cf80030b638aec17 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 28 Oct 2022 21:29:24 +0300 Subject: [PATCH 1/3] Reformat docs for odd_even_sort.py --- sorts/odd_even_sort.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sorts/odd_even_sort.py b/sorts/odd_even_sort.py index 532f829499e8..9ef4462c72c0 100644 --- a/sorts/odd_even_sort.py +++ b/sorts/odd_even_sort.py @@ -1,10 +1,15 @@ -"""For reference +""" +Odd even sort implementation. + https://en.wikipedia.org/wiki/Odd%E2%80%93even_sort """ def odd_even_sort(input_list: list) -> list: - """this algorithm uses the same idea of bubblesort, + """ + Sort input with odd even sort. + + This algorithm uses the same idea of bubblesort, but by first dividing in two phase (odd and even). Originally developed for use on parallel processors with local interconnections. From af489fbcd53d0eb8cba72afce064532afe96286d Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 29 Oct 2022 00:31:10 +0300 Subject: [PATCH 2/3] Fix docstring formatting --- machine_learning/data_transformations.py | 10 +++++++--- physics/kinetic_energy.py | 5 ++++- sorts/merge_sort.py | 11 ++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/machine_learning/data_transformations.py b/machine_learning/data_transformations.py index 9e0d747e93fa..ecfd3b9e27c2 100644 --- a/machine_learning/data_transformations.py +++ b/machine_learning/data_transformations.py @@ -1,5 +1,7 @@ """ -Normalization Wikipedia: https://en.wikipedia.org/wiki/Normalization +Normalization. + +Wikipedia: https://en.wikipedia.org/wiki/Normalization Normalization is the process of converting numerical data to a standard range of values. This range is typically between [0, 1] or [-1, 1]. The equation for normalization is x_norm = (x - x_min)/(x_max - x_min) where x_norm is the normalized value, x is the @@ -28,7 +30,8 @@ def normalization(data: list, ndigits: int = 3) -> list: """ - Returns a normalized list of values + Return a normalized list of values. + @params: data, a list of values to normalize @returns: a list of normalized values (rounded to ndigits decimal places) @examples: @@ -46,7 +49,8 @@ def normalization(data: list, ndigits: int = 3) -> list: def standardization(data: list, ndigits: int = 3) -> list: """ - Returns a standardized list of values + Return a standardized list of values. + @params: data, a list of values to standardize @returns: a list of standardized values (rounded to ndigits decimal places) @examples: diff --git a/physics/kinetic_energy.py b/physics/kinetic_energy.py index 535ffc219251..00c40005afaf 100644 --- a/physics/kinetic_energy.py +++ b/physics/kinetic_energy.py @@ -1,5 +1,6 @@ """ -Find the kinetic energy of an object, give its mass and velocity +Find the kinetic energy of an object, give its mass and velocity. + Description : In physics, the kinetic energy of an object is the energy that it possesses due to its motion. It is defined as the work needed to accelerate a body of a given mass from rest to its stated velocity. Having gained this energy during its @@ -19,6 +20,8 @@ def kinetic_energy(mass: float, velocity: float) -> float: """ + Calculate kinetick energy. + The kinetic energy of a non-rotating object of mass m traveling at a speed v is ½mv² >>> kinetic_energy(10,10) diff --git a/sorts/merge_sort.py b/sorts/merge_sort.py index 4da29f32a36d..547537304965 100644 --- a/sorts/merge_sort.py +++ b/sorts/merge_sort.py @@ -1,5 +1,6 @@ """ -This is a pure Python implementation of the merge sort algorithm +This is a pure Python implementation of the merge sort algorithm. + For doctests run following command: python -m doctest -v merge_sort.py or @@ -10,7 +11,9 @@ def merge_sort(collection: list) -> list: - """Pure implementation of the merge sort algorithm in Python + """ + Pure implementation of the merge sort algorithm in Python. + :param collection: some mutable ordered collection with heterogeneous comparable items inside :return: the same collection ordered by ascending @@ -24,7 +27,9 @@ def merge_sort(collection: list) -> list: """ def merge(left: list, right: list) -> list: - """merge left and right + """ + Merge left and right. + :param left: left collection :param right: right collection :return: merge result From 33b0d38b4864efaca2f0d243ac45164a9576fe91 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 29 Oct 2022 01:35:13 +0300 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Caeden Perelli-Harris --- physics/kinetic_energy.py | 2 +- sorts/merge_sort.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/physics/kinetic_energy.py b/physics/kinetic_energy.py index 00c40005afaf..8863919ac79f 100644 --- a/physics/kinetic_energy.py +++ b/physics/kinetic_energy.py @@ -1,5 +1,5 @@ """ -Find the kinetic energy of an object, give its mass and velocity. +Find the kinetic energy of an object, given its mass and velocity. Description : In physics, the kinetic energy of an object is the energy that it possesses due to its motion. It is defined as the work needed to accelerate a body of a diff --git a/sorts/merge_sort.py b/sorts/merge_sort.py index 547537304965..e80b1cb226ec 100644 --- a/sorts/merge_sort.py +++ b/sorts/merge_sort.py @@ -12,8 +12,6 @@ def merge_sort(collection: list) -> list: """ - Pure implementation of the merge sort algorithm in Python. - :param collection: some mutable ordered collection with heterogeneous comparable items inside :return: the same collection ordered by ascending