From 6ea3b000d0d477686c8ee3bd14b2ac22c5ae0379 Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Sun, 9 Oct 2022 17:20:58 +0200 Subject: [PATCH 01/22] Spheres union --- maths/volume.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/maths/volume.py b/maths/volume.py index acaed65f4858..a2a6a489fc9b 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -69,6 +69,26 @@ def vol_spheres_intersect( return vol_spherical_cap(h1, radius_2) + vol_spherical_cap(h2, radius_1) +def vol_spheres_union( + radius_1: float, radius_2: float, centers_distance: float +) -> float: + """ + Calculate the volume of the union of two spheres that possibly intersect. + The volume of the union is the sum of the volumes of sphere A and sphere B, less the intersection. + + First, it calculates the volumes (v1, v2) + of the spheres, then the volume of the intersection (i) and it returns the sum v1+v2-i. + if centers_distance is 0 then it returns the volume of the larger sphere + :return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) + + >>> vol_spheres_union(2, 2, 1) + 45.814892864851146 + """ + + if centers_distance == 0: + return vol_sphere(max(radius_1, radius_2)) + + return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) def vol_cuboid(width: float, height: float, length: float) -> float: """ @@ -216,6 +236,7 @@ def main(): print("Conical Frustum: " + str(vol_conical_frustum(2, 2, 4))) # ~= 58.6 print("Spherical cap: " + str(vol_spherical_cap(1, 2))) # ~= 5.24 print("Spheres intersetion: " + str(vol_spheres_intersect(2, 2, 1))) # ~= 21.21 + print("Spheres union: " + str(vol_spheres_union(2, 2, 1))) # ~= 45.81 if __name__ == "__main__": From 2317ca247bdff63d6b88372bfcb544f66f2c1d77 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 15:26:27 +0000 Subject: [PATCH 02/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index a2a6a489fc9b..a3df8338789e 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -69,13 +69,14 @@ def vol_spheres_intersect( return vol_spherical_cap(h1, radius_2) + vol_spherical_cap(h2, radius_1) + def vol_spheres_union( radius_1: float, radius_2: float, centers_distance: float ) -> float: """ - Calculate the volume of the union of two spheres that possibly intersect. + Calculate the volume of the union of two spheres that possibly intersect. The volume of the union is the sum of the volumes of sphere A and sphere B, less the intersection. - + First, it calculates the volumes (v1, v2) of the spheres, then the volume of the intersection (i) and it returns the sum v1+v2-i. if centers_distance is 0 then it returns the volume of the larger sphere @@ -84,11 +85,16 @@ def vol_spheres_union( >>> vol_spheres_union(2, 2, 1) 45.814892864851146 """ - + if centers_distance == 0: return vol_sphere(max(radius_1, radius_2)) - return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) + return ( + vol_sphere(radius_1) + + vol_sphere(radius_2) + - vol_spheres_intersect(radius_1, radius_2, centers_distance) + ) + def vol_cuboid(width: float, height: float, length: float) -> float: """ From 4585796f55979453b04b7eda44ee71304718224a Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Sun, 9 Oct 2022 17:32:15 +0200 Subject: [PATCH 03/22] Update volume.py --- maths/volume.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index a3df8338789e..03931fbfc2f8 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -69,32 +69,26 @@ def vol_spheres_intersect( return vol_spherical_cap(h1, radius_2) + vol_spherical_cap(h2, radius_1) - def vol_spheres_union( radius_1: float, radius_2: float, centers_distance: float ) -> float: """ - Calculate the volume of the union of two spheres that possibly intersect. - The volume of the union is the sum of the volumes of sphere A and sphere B, less the intersection. - + Calculate the volume of the union of two spheres that possibly intersect. + It is the sum of sphere A and sphere B minus their intersection. First, it calculates the volumes (v1, v2) of the spheres, then the volume of the intersection (i) and it returns the sum v1+v2-i. if centers_distance is 0 then it returns the volume of the larger sphere - :return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) + :return vol_sphere(radius_1) + vol_sphere(radius_2) + - vol_spheres_intersect(radius_1, radius_2, centers_distance) >>> vol_spheres_union(2, 2, 1) 45.814892864851146 """ - + if centers_distance == 0: return vol_sphere(max(radius_1, radius_2)) - return ( - vol_sphere(radius_1) - + vol_sphere(radius_2) - - vol_spheres_intersect(radius_1, radius_2, centers_distance) - ) - + return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) def vol_cuboid(width: float, height: float, length: float) -> float: """ From f2d1867331583e85981ee67b9bc6a6f62585844c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 15:33:07 +0000 Subject: [PATCH 04/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 03931fbfc2f8..8e23a1fc1899 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -69,26 +69,32 @@ def vol_spheres_intersect( return vol_spherical_cap(h1, radius_2) + vol_spherical_cap(h2, radius_1) + def vol_spheres_union( radius_1: float, radius_2: float, centers_distance: float ) -> float: """ - Calculate the volume of the union of two spheres that possibly intersect. + Calculate the volume of the union of two spheres that possibly intersect. It is the sum of sphere A and sphere B minus their intersection. First, it calculates the volumes (v1, v2) of the spheres, then the volume of the intersection (i) and it returns the sum v1+v2-i. if centers_distance is 0 then it returns the volume of the larger sphere - :return vol_sphere(radius_1) + vol_sphere(radius_2) + :return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) >>> vol_spheres_union(2, 2, 1) 45.814892864851146 """ - + if centers_distance == 0: return vol_sphere(max(radius_1, radius_2)) - return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) + return ( + vol_sphere(radius_1) + + vol_sphere(radius_2) + - vol_spheres_intersect(radius_1, radius_2, centers_distance) + ) + def vol_cuboid(width: float, height: float, length: float) -> float: """ From 73337b0837bd0e59fa593e3cbe63c1f431199168 Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Sun, 9 Oct 2022 17:35:29 +0200 Subject: [PATCH 05/22] Update volume.py --- maths/volume.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 8e23a1fc1899..9d3f2f79d931 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -69,32 +69,26 @@ def vol_spheres_intersect( return vol_spherical_cap(h1, radius_2) + vol_spherical_cap(h2, radius_1) - def vol_spheres_union( radius_1: float, radius_2: float, centers_distance: float ) -> float: """ - Calculate the volume of the union of two spheres that possibly intersect. + Calculate the volume of the union of two spheres that possibly intersect. It is the sum of sphere A and sphere B minus their intersection. - First, it calculates the volumes (v1, v2) - of the spheres, then the volume of the intersection (i) and it returns the sum v1+v2-i. - if centers_distance is 0 then it returns the volume of the larger sphere - :return vol_sphere(radius_1) + vol_sphere(radius_2) + First, it calculates the volumes (v1, v2) of the spheres, + then the volume of the intersection (i) and it returns the sum v1+v2-i. + If centers_distance is 0 then it returns the volume of the larger sphere + :return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) >>> vol_spheres_union(2, 2, 1) 45.814892864851146 """ - + if centers_distance == 0: return vol_sphere(max(radius_1, radius_2)) - return ( - vol_sphere(radius_1) - + vol_sphere(radius_2) - - vol_spheres_intersect(radius_1, radius_2, centers_distance) - ) - + return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) def vol_cuboid(width: float, height: float, length: float) -> float: """ From fd2f2a343542fa81e31607217258a3f7192f0ff5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 15:36:22 +0000 Subject: [PATCH 06/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 9d3f2f79d931..7bc2ad6f1823 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -69,26 +69,32 @@ def vol_spheres_intersect( return vol_spherical_cap(h1, radius_2) + vol_spherical_cap(h2, radius_1) + def vol_spheres_union( radius_1: float, radius_2: float, centers_distance: float ) -> float: """ - Calculate the volume of the union of two spheres that possibly intersect. + Calculate the volume of the union of two spheres that possibly intersect. It is the sum of sphere A and sphere B minus their intersection. - First, it calculates the volumes (v1, v2) of the spheres, + First, it calculates the volumes (v1, v2) of the spheres, then the volume of the intersection (i) and it returns the sum v1+v2-i. If centers_distance is 0 then it returns the volume of the larger sphere - :return vol_sphere(radius_1) + vol_sphere(radius_2) + :return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) >>> vol_spheres_union(2, 2, 1) 45.814892864851146 """ - + if centers_distance == 0: return vol_sphere(max(radius_1, radius_2)) - return vol_sphere(radius_1) + vol_sphere(radius_2) - vol_spheres_intersect(radius_1, radius_2, centers_distance) + return ( + vol_sphere(radius_1) + + vol_sphere(radius_2) + - vol_spheres_intersect(radius_1, radius_2, centers_distance) + ) + def vol_cuboid(width: float, height: float, length: float) -> float: """ From 8b2ff50f14a6814e9829abfd7d1c15aa4955e2e9 Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Fri, 21 Oct 2022 08:20:37 +0200 Subject: [PATCH 07/22] f-strings --- maths/volume.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 40ed8bcccd78..c83a273fabb4 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -418,19 +418,19 @@ def vol_conical_frustum(height: float, radius_1: float, radius_2: float) -> floa def main(): """Print the Results of Various Volume Calculations.""" print("Volumes:") - print("Cube: " + str(vol_cube(2))) # = 8 - print("Cuboid: " + str(vol_cuboid(2, 2, 2))) # = 8 - print("Cone: " + str(vol_cone(2, 2))) # ~= 1.33 - print("Right Circular Cone: " + str(vol_right_circ_cone(2, 2))) # ~= 8.38 - print("Prism: " + str(vol_prism(2, 2))) # = 4 - print("Pyramid: " + str(vol_pyramid(2, 2))) # ~= 1.33 - print("Sphere: " + str(vol_sphere(2))) # ~= 33.5 - print("Hemisphere: " + str(vol_hemisphere(2))) # ~= 16.75 - print("Circular Cylinder: " + str(vol_circular_cylinder(2, 2))) # ~= 25.1 - print("Conical Frustum: " + str(vol_conical_frustum(2, 2, 4))) # ~= 58.6 - print("Spherical cap: " + str(vol_spherical_cap(1, 2))) # ~= 5.24 - print("Spheres intersetion: " + str(vol_spheres_intersect(2, 2, 1))) # ~= 21.21 - print("Spheres union: " + str(vol_spheres_union(2, 2, 1))) # ~= 45.81 + print(f"Cube: {vol_cube(2) = }") # = 8 + print(f"Cuboid: {vol_cuboid(2, 2, 2) = }") # = 8 + print(f"Cone: {vol_cone(2, 2) = }") # ~= 1.33 + print(f"Right Circular Cone: {vol_right_circ_cone(2, 2) = }") # ~= 8.38 + print(f"Prism: {vol_prism(2, 2) = }") # = 4 + print(f"Pyramid: {vol_pyramid(2, 2) = }") # ~= 1.33 + print(f"Sphere: {vol_sphere(2) = }") # ~= 33.5 + print(f"Hemisphere: {vol_hemisphere(2) = }") # ~= 16.75 + print(f"Circular Cylinder: {vol_circular_cylinder(2, 2) = }") # ~= 25.1 + print(f"Conical Frustum: {vol_conical_frustum(2, 2, 4) = }") # ~= 58.6 + print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 + print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 + print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 print( f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" ) # ~= 28.3 From 794b98ccb71bf0f3d672a12a9e44479d41abadff Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 14:21:12 +0200 Subject: [PATCH 08/22] Update maths/volume.py Co-authored-by: Christian Clauss --- maths/volume.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index c83a273fabb4..77bf0192d471 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -431,9 +431,8 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - print( - f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" - ) # ~= 28.3 + # ~= 28.3 + print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") if __name__ == "__main__": From 4d9c4157f099a724bb43e62e8b800265edab8440 Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 17:22:48 +0200 Subject: [PATCH 09/22] more tests --- maths/volume.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/maths/volume.py b/maths/volume.py index 29fc2b1757f1..2234b2e2fd0c 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -122,6 +122,21 @@ def vol_spheres_union( >>> vol_spheres_union(2, 2, 1) 45.814892864851146 + + >>> vol_spheres_union(1.56, 2.2, 1.4) + 48.77802773671288 + + >>> vol_spheres_union(-1, 2, 1) + Traceback (most recent call last): + + >>> vol_spheres_union(0, 2, 1) + Traceback (most recent call last): + + >>> vol_spheres_union('1.56', '2.2', '1.4') + Traceback (most recent call last): + + >>> vol_spheres_union(1, None, 1) + Traceback (most recent call last): """ if centers_distance == 0: From ae9d9e253ce85ab527f8d352936b4640215cf39e Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 17:34:11 +0200 Subject: [PATCH 10/22] fix non negative --- maths/volume.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 2234b2e2fd0c..20326e4e20a3 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -126,9 +126,6 @@ def vol_spheres_union( >>> vol_spheres_union(1.56, 2.2, 1.4) 48.77802773671288 - >>> vol_spheres_union(-1, 2, 1) - Traceback (most recent call last): - >>> vol_spheres_union(0, 2, 1) Traceback (most recent call last): @@ -139,6 +136,9 @@ def vol_spheres_union( Traceback (most recent call last): """ + if radius_1 < 0 or radius_2 < 0 or centers_distance < 0: + raise ValueError("vol_spheres_union() only accepts non-negative values") + if centers_distance == 0: return vol_sphere(max(radius_1, radius_2)) From b7510d04d0be3f9e052cf7c6e9a2bbb2c7abf36a Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 17:44:49 +0200 Subject: [PATCH 11/22] fix 0 radius --- maths/volume.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 20326e4e20a3..ab087238124a 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -136,8 +136,8 @@ def vol_spheres_union( Traceback (most recent call last): """ - if radius_1 < 0 or radius_2 < 0 or centers_distance < 0: - raise ValueError("vol_spheres_union() only accepts non-negative values") + if radius_1 <= 0 or radius_2 <= 0 or centers_distance < 0: + raise ValueError("vol_spheres_union() only accepts non-negative values, non-zero radius") if centers_distance == 0: return vol_sphere(max(radius_1, radius_2)) From 940fc1cfaa9ea7a5440bfb6f70c874dc776c5606 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Oct 2022 15:47:05 +0000 Subject: [PATCH 12/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maths/volume.py b/maths/volume.py index ab087238124a..d36db17b30aa 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -137,7 +137,9 @@ def vol_spheres_union( """ if radius_1 <= 0 or radius_2 <= 0 or centers_distance < 0: - raise ValueError("vol_spheres_union() only accepts non-negative values, non-zero radius") + raise ValueError( + "vol_spheres_union() only accepts non-negative values, non-zero radius" + ) if centers_distance == 0: return vol_sphere(max(radius_1, radius_2)) From 0cdf596831bbb03b0dcd8f83035e2bcdb23cff10 Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 17:55:34 +0200 Subject: [PATCH 13/22] fix tests --- maths/volume.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index d36db17b30aa..9c581845cb01 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -122,18 +122,20 @@ def vol_spheres_union( >>> vol_spheres_union(2, 2, 1) 45.814892864851146 - >>> vol_spheres_union(1.56, 2.2, 1.4) 48.77802773671288 - >>> vol_spheres_union(0, 2, 1) Traceback (most recent call last): - + ... + ValueError('vol_spheres_union() only accepts non-negative values, non-zero radius') >>> vol_spheres_union('1.56', '2.2', '1.4') Traceback (most recent call last): - + ... + TypeError: '<=' not supported between instances of 'str' and 'int' >>> vol_spheres_union(1, None, 1) Traceback (most recent call last): + ... + TypeError: '<=' not supported between instances of 'NoneType' and 'int' """ if radius_1 <= 0 or radius_2 <= 0 or centers_distance < 0: @@ -455,8 +457,7 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - # ~= 28.3 - print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") + print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") # ~= 28.3 if __name__ == "__main__": From f2957439626504f476004fe62d24e43546fe9c22 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Oct 2022 15:56:22 +0000 Subject: [PATCH 14/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maths/volume.py b/maths/volume.py index 9c581845cb01..ab290627a734 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -457,7 +457,9 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") # ~= 28.3 + print( + f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" + ) # ~= 28.3 if __name__ == "__main__": From d0d2d2abdd5453655b8d3553eda4669bc5af37f7 Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:01:55 +0200 Subject: [PATCH 15/22] fix tests --- maths/volume.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/volume.py b/maths/volume.py index ab290627a734..007f6272e5aa 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -127,7 +127,7 @@ def vol_spheres_union( >>> vol_spheres_union(0, 2, 1) Traceback (most recent call last): ... - ValueError('vol_spheres_union() only accepts non-negative values, non-zero radius') + ValueError: vol_spheres_union() only accepts non-negative values, non-zero radius >>> vol_spheres_union('1.56', '2.2', '1.4') Traceback (most recent call last): ... From 39536fd60f4289f23b9a2270a66534309e87e79a Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:07:29 +0200 Subject: [PATCH 16/22] fix print --- maths/volume.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 007f6272e5aa..3f06a9285125 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -457,9 +457,7 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - print( - f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" - ) # ~= 28.3 + print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") # ~= 28.3 if __name__ == "__main__": From 6b8b27b4b2e802a932db2bdbbd4958428dd84008 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Oct 2022 16:12:02 +0000 Subject: [PATCH 17/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maths/volume.py b/maths/volume.py index 3f06a9285125..007f6272e5aa 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -457,7 +457,9 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") # ~= 28.3 + print( + f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" + ) # ~= 28.3 if __name__ == "__main__": From 15c263451ee0264dbe22c298c2418869d6eafb54 Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:17:29 +0200 Subject: [PATCH 18/22] fix comment --- maths/volume.py | 1 - 1 file changed, 1 deletion(-) diff --git a/maths/volume.py b/maths/volume.py index 007f6272e5aa..0f6827c87c6a 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -461,6 +461,5 @@ def main(): f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" ) # ~= 28.3 - if __name__ == "__main__": main() From 2e1ca030c263c6b1e7082a6148c20a07d727347b Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:17:49 +0200 Subject: [PATCH 19/22] fix comment --- maths/volume.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 0f6827c87c6a..b488e576edfa 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -457,9 +457,7 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - print( - f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" - ) # ~= 28.3 + print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") # ~= 28.3 if __name__ == "__main__": main() From 55a80848772f71cc9afd3826e505aefdce371530 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Oct 2022 16:20:15 +0000 Subject: [PATCH 20/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/maths/volume.py b/maths/volume.py index b488e576edfa..007f6272e5aa 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -457,7 +457,10 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") # ~= 28.3 + print( + f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" + ) # ~= 28.3 + if __name__ == "__main__": main() From 3893e2fef03ebd9be7479ec9a8fd0c3647292c03 Mon Sep 17 00:00:00 2001 From: Matteo Messmer <40521259+matteomessmer@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:23:12 +0200 Subject: [PATCH 21/22] Update volume.py --- maths/volume.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/maths/volume.py b/maths/volume.py index 007f6272e5aa..af9e371a14a8 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -457,10 +457,7 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - print( - f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" - ) # ~= 28.3 - + print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") # ~= 28.3 if __name__ == "__main__": main() From a098e3a52a676c8827da6132b5dcc29f12cca411 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Oct 2022 16:24:19 +0000 Subject: [PATCH 22/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/maths/volume.py b/maths/volume.py index af9e371a14a8..da4054646659 100644 --- a/maths/volume.py +++ b/maths/volume.py @@ -457,7 +457,10 @@ def main(): print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24 print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21 print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81 - print(f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }") # ~= 28.3 + print( + f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }" + ) # ~= 28.3 + if __name__ == "__main__": main()