From 1f470e7932be67d1e6aa7751dd8a02c8011870c7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:30:51 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- audio_filters/butterworth_filter.py | 6 +++--- maths/pythagoras.py | 7 +++---- sorts/quick_sort.py | 5 ++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/audio_filters/butterworth_filter.py b/audio_filters/butterworth_filter.py index 87160a4ef..a4a273a64 100644 --- a/audio_filters/butterworth_filter.py +++ b/audio_filters/butterworth_filter.py @@ -113,7 +113,7 @@ def make_allpass( >>> filter = make_allpass(1000, 48000) >>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE - [1.0922959556412573, -1.9828897227476208, 0.9077040443587427, + [1.0922959556412573, -1.9828897227476208, 0.9077040443587427, 0.9077040443587427, -1.9828897227476208, 1.0922959556412573] """ w0 = tau * frequency / samplerate @@ -173,7 +173,7 @@ def make_lowshelf( >>> filter = make_lowshelf(1000, 48000, 6) >>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE - [3.0409336710888786, -5.608870992220748, 2.602157875636628, + [3.0409336710888786, -5.608870992220748, 2.602157875636628, 3.139954022810743, -5.591841778072785, 2.5201667380627257] """ w0 = tau * frequency / samplerate @@ -210,7 +210,7 @@ def make_highshelf( >>> filter = make_highshelf(1000, 48000, 6) >>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE - [2.2229172136088806, -3.9587208137297303, 1.7841414181566304, + [2.2229172136088806, -3.9587208137297303, 1.7841414181566304, 4.295432981120543, -7.922740859457287, 3.6756456963725253] """ w0 = tau * frequency / samplerate diff --git a/maths/pythagoras.py b/maths/pythagoras.py index 94c7cc7e5..bf17c8025 100644 --- a/maths/pythagoras.py +++ b/maths/pythagoras.py @@ -1,4 +1,4 @@ -"""Uses Pythagoras theorem +"""Uses Pythagoras theorem to calculate the distance between two points in space.""" import math @@ -18,12 +18,11 @@ def distance(a: Point, b: Point) -> float: """ >>> point1 = Point(2, -1, 7) >>> point2 = Point(1, -3, 5) - >>> print(f"Distance from {point1} to {point2} + >>> print(f"Distance from {point1} to {point2} is {distance(point1, point2)}") Distance from Point(2, -1, 7) to Point(1, -3, 5) is 3.0 """ - return math.sqrt(abs((b.x - a.x) ** 2 + (b.y - a.y) ** 2 - + (b.z - a.z) ** 2)) + return math.sqrt(abs((b.x - a.x) ** 2 + (b.y - a.y) ** 2 + (b.z - a.z) ** 2)) if __name__ == "__main__": diff --git a/sorts/quick_sort.py b/sorts/quick_sort.py index 03c7f54b3..95a105fca 100644 --- a/sorts/quick_sort.py +++ b/sorts/quick_sort.py @@ -35,12 +35,11 @@ def quick_sort(collection: list) -> list: lesser_partition, greater_partition = partition(collection, pivot) - return [*quick_sort(lesser_partition), pivot, - *quick_sort(greater_partition)] + return [*quick_sort(lesser_partition), pivot, *quick_sort(greater_partition)] def partition(collection: list, pivot) -> tuple[list, list]: - """Partition the collection into two lists: elements less + """Partition the collection into two lists: elements less than or equal to the pivot, and elements greater than the pivot. :param collection: a mutable collection of comparable items :param pivot: the pivot element