Skip to content

Commit

Permalink
Added to_number function to misc_utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Aug 6, 2024
1 parent a32edd4 commit 247eb8b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dcicutils/misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from collections import namedtuple
from collections.abc import Iterable
import appdirs
from copy import deepcopy
import concurrent.futures
Expand Down Expand Up @@ -2870,6 +2871,6 @@ def create_short_uuid(length: Optional[int] = None, upper: bool = False):
return value


def run_concurrently(functions: List[Callable], nthreads: int = 4) -> None:
def run_concurrently(functions: Iterable[Callable], nthreads: int = 4) -> None:
with concurrent.futures.ThreadPoolExecutor(max_workers=nthreads) as executor:
[_ for _ in concurrent.futures.as_completed([executor.submit(f) for f in functions])]
concurrent.futures.as_completed([executor.submit(f) for f in functions])
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "8.13.3.1b15" # TODO: To become 8.14.0
version = "8.13.3.1b16" # TODO: To become 8.14.0
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions test/test_misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3746,6 +3746,7 @@ def test_to_number():
assert to_number("4T", allow_suffix=True) == 4000000000000
assert to_number("4Tb", allow_suffix=True) == 4000000000000
assert to_number("4TB", allow_suffix=True) == 4000000000000
assert to_number("4k", allow_suffix=True) is None
assert to_number("1,234,567K", allow_commas=True) is None
assert to_number("1,234,567K", allow_commas=True, allow_suffix=True) == 1234567000
assert to_number("-1,234,567K", allow_commas=True, allow_suffix=True) == -1234567000
Expand Down

0 comments on commit 247eb8b

Please sign in to comment.