From 4535283554efea10db06919b73c77c825e8e9d2f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 1 Aug 2020 05:53:23 +0200 Subject: [PATCH] Re-blacken (#2246) * Avoid double spaces * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> --- linear_algebra/src/test_linear_algebra.py | 9 +- maths/number_of_digits.py | 118 ++++++++++++++-------- web_programming/daily_horoscope.py | 2 +- 3 files changed, 79 insertions(+), 50 deletions(-) diff --git a/linear_algebra/src/test_linear_algebra.py b/linear_algebra/src/test_linear_algebra.py index be6245747..8db480ceb 100644 --- a/linear_algebra/src/test_linear_algebra.py +++ b/linear_algebra/src/test_linear_algebra.py @@ -8,14 +8,7 @@ This file contains the test-suite for the linear algebra library. """ import unittest -from lib import ( - Matrix, - Vector, - axpy, - squareZeroMatrix, - unitBasisVector, - zeroVector, -) +from lib import Matrix, Vector, axpy, squareZeroMatrix, unitBasisVector, zeroVector class Test(unittest.TestCase): diff --git a/maths/number_of_digits.py b/maths/number_of_digits.py index 4bafa613c..ca4cce876 100644 --- a/maths/number_of_digits.py +++ b/maths/number_of_digits.py @@ -28,7 +28,7 @@ def num_digits_fast(n: int) -> int: >>> num_digits_fast(123) 3 """ - return (math.floor(math.log(abs(n), 10) + 1)) + return math.floor(math.log(abs(n), 10) + 1) def num_digits_faster(n: int) -> int: @@ -41,7 +41,7 @@ def num_digits_faster(n: int) -> int: >>> num_digits_faster(123) 3 """ - return (len(str(abs(n)))) + return len(str(abs(n))) def benchmark() -> None: @@ -49,47 +49,83 @@ def benchmark() -> None: Benchmark code for comparing 3 functions, with 3 different length int values. """ - print('\nFor small_num = ', small_num, ':') - print("> num_digits()", - '\t\tans =', num_digits(small_num), - '\ttime =', timeit("z.num_digits(z.small_num)", - setup="import __main__ as z"), "seconds") - print("> num_digits_fast()", - '\tans =', num_digits_fast(small_num), - '\ttime =', timeit("z.num_digits_fast(z.small_num)", - setup="import __main__ as z"), "seconds") - print("> num_digits_faster()", - '\tans =', num_digits_faster(small_num), - '\ttime =', timeit("z.num_digits_faster(z.small_num)", - setup="import __main__ as z"), "seconds") + print("\nFor small_num = ", small_num, ":") + print( + "> num_digits()", + "\t\tans =", + num_digits(small_num), + "\ttime =", + timeit("z.num_digits(z.small_num)", setup="import __main__ as z"), + "seconds", + ) + print( + "> num_digits_fast()", + "\tans =", + num_digits_fast(small_num), + "\ttime =", + timeit("z.num_digits_fast(z.small_num)", setup="import __main__ as z"), + "seconds", + ) + print( + "> num_digits_faster()", + "\tans =", + num_digits_faster(small_num), + "\ttime =", + timeit("z.num_digits_faster(z.small_num)", setup="import __main__ as z"), + "seconds", + ) - print('\nFor medium_num = ', medium_num, ':') - print("> num_digits()", - '\t\tans =', num_digits(medium_num), - '\ttime =', timeit("z.num_digits(z.medium_num)", - setup="import __main__ as z"), "seconds") - print("> num_digits_fast()", - '\tans =', num_digits_fast(medium_num), - '\ttime =', timeit("z.num_digits_fast(z.medium_num)", - setup="import __main__ as z"), "seconds") - print("> num_digits_faster()", - '\tans =', num_digits_faster(medium_num), - '\ttime =', timeit("z.num_digits_faster(z.medium_num)", - setup="import __main__ as z"), "seconds") + print("\nFor medium_num = ", medium_num, ":") + print( + "> num_digits()", + "\t\tans =", + num_digits(medium_num), + "\ttime =", + timeit("z.num_digits(z.medium_num)", setup="import __main__ as z"), + "seconds", + ) + print( + "> num_digits_fast()", + "\tans =", + num_digits_fast(medium_num), + "\ttime =", + timeit("z.num_digits_fast(z.medium_num)", setup="import __main__ as z"), + "seconds", + ) + print( + "> num_digits_faster()", + "\tans =", + num_digits_faster(medium_num), + "\ttime =", + timeit("z.num_digits_faster(z.medium_num)", setup="import __main__ as z"), + "seconds", + ) - print('\nFor large_num = ', large_num, ':') - print("> num_digits()", - '\t\tans =', num_digits(large_num), - '\ttime =', timeit("z.num_digits(z.large_num)", - setup="import __main__ as z"), "seconds") - print("> num_digits_fast()", - '\tans =', num_digits_fast(large_num), - '\ttime =', timeit("z.num_digits_fast(z.large_num)", - setup="import __main__ as z"), "seconds") - print("> num_digits_faster()", - '\tans =', num_digits_faster(large_num), - '\ttime =', timeit("z.num_digits_faster(z.large_num)", - setup="import __main__ as z"), "seconds") + print("\nFor large_num = ", large_num, ":") + print( + "> num_digits()", + "\t\tans =", + num_digits(large_num), + "\ttime =", + timeit("z.num_digits(z.large_num)", setup="import __main__ as z"), + "seconds", + ) + print( + "> num_digits_fast()", + "\tans =", + num_digits_fast(large_num), + "\ttime =", + timeit("z.num_digits_fast(z.large_num)", setup="import __main__ as z"), + "seconds", + ) + print( + "> num_digits_faster()", + "\tans =", + num_digits_faster(large_num), + "\ttime =", + timeit("z.num_digits_faster(z.large_num)", setup="import __main__ as z"), + "seconds", + ) if __name__ == "__main__": diff --git a/web_programming/daily_horoscope.py b/web_programming/daily_horoscope.py index ecb37ce10..b0dd1cd65 100644 --- a/web_programming/daily_horoscope.py +++ b/web_programming/daily_horoscope.py @@ -1,5 +1,5 @@ -from bs4 import BeautifulSoup import requests +from bs4 import BeautifulSoup def horoscope(zodiac_sign: int, day: str) -> str: