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>
This commit is contained in:
Christian Clauss 2020-08-01 05:53:23 +02:00 committed by GitHub
parent e2ee52d773
commit 4535283554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 50 deletions

View File

@ -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):

View File

@ -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__":

View File

@ -1,5 +1,5 @@
from bs4 import BeautifulSoup
import requests
from bs4 import BeautifulSoup
def horoscope(zodiac_sign: int, day: str) -> str: