psf/black changes to next_greater_element.py (#1817)

* psf/black changes to next_greater_element.py

* 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-03-28 07:24:59 +01:00
committed by GitHub
parent 96df906e7a
commit f17e9822b0
2 changed files with 51 additions and 37 deletions

View File

@ -38,19 +38,21 @@ def allocation_num(number_of_bytes: int, partitions: int) -> List[str]:
ValueError: partitions must be a positive number!
"""
if partitions <= 0:
raise ValueError('partitions must be a positive number!')
raise ValueError("partitions must be a positive number!")
if partitions >= number_of_bytes:
raise ValueError('partitions can not >= number_of_bytes!')
raise ValueError("partitions can not >= number_of_bytes!")
bytes_per_partition = number_of_bytes // partitions
allocation_list = [f'0-{bytes_per_partition}']
allocation_list = [f"0-{bytes_per_partition}"]
for i in range(1, partitions - 1):
length = f'{bytes_per_partition * i + 1}-{bytes_per_partition * (i + 1)}'
length = f"{bytes_per_partition * i + 1}-{bytes_per_partition * (i + 1)}"
allocation_list.append(length)
allocation_list.append(f'{(bytes_per_partition * (partitions - 1)) + 1}-'
f'{number_of_bytes}')
allocation_list.append(
f"{(bytes_per_partition * (partitions - 1)) + 1}-" f"{number_of_bytes}"
)
return allocation_list
if __name__ == '__main__':
if __name__ == "__main__":
import doctest
doctest.testmod()