dev: remove unique_id system, not needed for now

- wrong assumption when reading hnp's code, for now unique ids are not
needed
This commit is contained in:
Arthur Meyre
2021-07-21 10:38:59 +02:00
parent 1a54bc1f22
commit 29c1641f48
4 changed files with 1 additions and 39 deletions

View File

@@ -1,2 +1,2 @@
"""HDK's top import"""
from . import common, utils
from . import common

View File

@@ -1,3 +0,0 @@
"""HDK's utils module"""
from . import misc
from .misc import *

View File

@@ -1,18 +0,0 @@
"""Misc. utils for hdk"""
from typing import Iterator
def get_unique_id() -> int:
"""Function to get a unique ID"""
if not hasattr(get_unique_id, "generator"):
def generator() -> Iterator[int]:
current_id = 0
while True:
yield current_id
current_id += 1
setattr(get_unique_id, "generator", generator())
return next(getattr(get_unique_id, "generator"))

View File

@@ -1,17 +0,0 @@
"""Test file for HDK's misc utils"""
import random
import hdk
def test_get_unique_id():
"""Test get_unique_id"""
how_many_ids = random.randint(2, 100)
generated_ids = [hdk.utils.get_unique_id() for __ in range(how_many_ids)]
len_generated_ids = len(generated_ids)
len_unique_ids = len(set(generated_ids))
assert (
len_generated_ids == len_unique_ids
), f"Expected to have uniques ids, generated {len_generated_ids}, only had {len_unique_ids}"