Commit 4d28ff6a authored by juga's avatar juga
Browse files

fix: style: Remove spaces around power operators

if both operands are simple. To make CI tests pass with new black
version 22.1 (#2726).

Closes #40123
parent ff1d3003
......@@ -786,7 +786,7 @@ def process_completed_futures(executor, hbeat, result_dump, pending_results):
virtualMemoryInfo = psutil.virtual_memory()
availableMemory = virtualMemoryInfo.available
log.warning(
"Memory available %s MB.", availableMemory / 1024 ** 2
"Memory available %s MB.", availableMemory / 1024**2
)
dumpstacks()
else:
......
......@@ -569,7 +569,7 @@ def _validate_section_ports(conf, sec, ports, tmpl):
errors = []
section = conf[sec]
for key in ports:
valid, error = _validate_int(section, key, minimum=1, maximum=2 ** 16)
valid, error = _validate_int(section, key, minimum=1, maximum=2**16)
if not valid:
errors.append(
tmpl.substitute(
......
......@@ -47,7 +47,7 @@ def sbws_required_disk_space(conf):
v3bw_max_space_after_delete = (
space_v3bw_files_day * v3bw_compress_after_days
) + (size_compressed_files * num_v3bw_files_day * v3bw_delete_after_days)
text_dict["mb_bw"] = round(v3bw_max_space_after_delete / 1000 ** 2)
text_dict["mb_bw"] = round(v3bw_max_space_after_delete / 1000**2)
text_dict["d_bw"] = v3bw_delete_after_days
# default crontab configuration will run cleanup once a day
# default cleanup configuration will compress v3bw files after 1 day
......@@ -63,7 +63,7 @@ def sbws_required_disk_space(conf):
) + (
size_compressed_files * num_v3bw_files_day * results_delete_after_days
)
text_dict["mb_results"] = round(results_max_space_after_delete / 1000 ** 2)
text_dict["mb_results"] = round(results_max_space_after_delete / 1000**2)
text_dict["d_r"] = results_delete_after_days
# not counted rotated files and assuming that when it is not rotated the
# size will be approximately 10MiB
......@@ -75,10 +75,10 @@ def sbws_required_disk_space(conf):
text_dict["mb_log"] = space_log_files
# roughly, size of a current tor dir
size_tor_dir = 19828000
text_dict["mb_tor"] = round(size_tor_dir / 1000 ** 2)
text_dict["mb_tor"] = round(size_tor_dir / 1000**2)
# roughly, the size of this code and dependencies
size_code_deps = 2097152
text_dict["mb_code"] = round(size_code_deps / 1000 ** 2)
text_dict["mb_code"] = round(size_code_deps / 1000**2)
# Multiply per 2, just in case
size_total = (
results_max_space_after_delete
......@@ -87,7 +87,7 @@ def sbws_required_disk_space(conf):
+ size_tor_dir
+ size_code_deps
) * 2
text_dict["mb_total"] = round(size_total / 1000 ** 2)
text_dict["mb_total"] = round(size_total / 1000**2)
space_text = DISK_SPACE_TEXT.format(**text_dict)
return space_text
......@@ -96,7 +96,7 @@ def df(path):
# Not being used, since it makes a disk space system call and some
# systems might not allow it
"""Return space left on device where path is in MiB."""
return round(shutil.disk_usage(path).free / (1024 ** 2))
return round(shutil.disk_usage(path).free / (1024**2))
def is_low_space(conf):
......
......@@ -174,7 +174,7 @@ def test_num_results_of_type(result_success, result_error_stream):
def assert_round_sig_dig_any_digits(n, result):
"""Test that rounding n to any reasonable number of significant digits
produces result."""
max_digits_int64 = int(math.ceil(math.log10(2 ** 64 - 1))) + 1
max_digits_int64 = int(math.ceil(math.log10(2**64 - 1))) + 1
for d in range(1, max_digits_int64 + 1):
assert round_sig_dig(n, digits=d) == result
......@@ -182,7 +182,7 @@ def assert_round_sig_dig_any_digits(n, result):
def assert_round_sig_dig_any_digits_error(n, elp_fraction=0.5):
"""Test that rounding n to any reasonable number of significant digits
produces a result within elp_fraction * 10.0 ** -(digits - 1)."""
max_digits_int64 = int(math.ceil(math.log10(2 ** 64 - 1))) + 1
max_digits_int64 = int(math.ceil(math.log10(2**64 - 1))) + 1
for d in range(1, max_digits_int64 + 1):
error_fraction = elp_fraction * (10.0 ** -(d - 1))
# use ceil rather than round, to work around floating-point inaccuracy
......@@ -259,21 +259,21 @@ def test_round_sig_dig():
assert_round_sig_dig_any_digits(10, 10)
# Large values
assert_round_sig_dig_any_digits_error(2 ** 30)
assert_round_sig_dig_any_digits_error(2 ** 31)
assert_round_sig_dig_any_digits_error(2 ** 32)
assert_round_sig_dig_any_digits_error(2**30)
assert_round_sig_dig_any_digits_error(2**31)
assert_round_sig_dig_any_digits_error(2**32)
# the floating-point accuracy limit for this function is 2**73
# on some machines
assert_round_sig_dig_any_digits_error(2 ** 62)
assert_round_sig_dig_any_digits_error(2 ** 63)
assert_round_sig_dig_any_digits_error(2 ** 64)
assert_round_sig_dig_any_digits_error(2**62)
assert_round_sig_dig_any_digits_error(2**63)
assert_round_sig_dig_any_digits_error(2**64)
# Out of range values: must round to 1
assert_round_sig_dig_any_digits(-0.01, 1)
assert_round_sig_dig_any_digits(-1, 1)
assert_round_sig_dig_any_digits(-10.5, 1)
assert_round_sig_dig_any_digits(-(2 ** 31), 1)
assert_round_sig_dig_any_digits(-(2**31), 1)
# test the transition points in the supported range
# testing the entire range up to 1 million takes 100s
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment