mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
851c740d21
commit
1f470e7932
|
@ -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
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user