Spaces:
Sleeping
Sleeping
Download DI-engine/ding/interaction/tests/test_utils/random.py from OpenDILabCommunity/gomoku: direct link, hf CLI and curl.
- Browser
- Download file 417 Bytes
-
https://huggingface.co/spaces/OpenDILabCommunity/gomoku/resolve/main/DI-engine/ding/interaction/tests/test_utils/random.py
- Command line
-
hf download hf://spaces/OpenDILabCommunity/gomoku/DI-engine/ding/interaction/tests/test_utils/random.py
-
curl -L -o random.py https://huggingface.co/spaces/OpenDILabCommunity/gomoku/resolve/main/DI-engine/ding/interaction/tests/test_utils/random.py
417 Bytes
| import random | |
| from typing import Iterable | |
| def random_port(excludes: Iterable[int] = None) -> int: | |
| return random.choice(list(set(range(10000, 20000)) - set(excludes or []))) | |
| def random_channel(excludes: Iterable[int] = None) -> int: | |
| excludes = set(list(excludes or [])) | |
| while True: | |
| _channel = random.randint(1000, (1 << 31) - 1) | |
| if _channel not in excludes: | |
| return _channel | |