# Path: guacamol/utils/data.py
# def get_random_subset(dataset: List[Any], subset_size: int, seed: Optional[int] = None) -> List[Any]:
#     """
#     Get a random subset of some dataset.
# 
#     For reproducibility, the random number generator seed can be specified.
#     Nevertheless, the state of the random number generator is restored to avoid side effects.
# 
#     Args:
#         dataset: full set to select a subset from
#         subset_size: target size of the subset
#         seed: random number generator seed. Defaults to not setting the seed.
# 
#     Returns:
#         subset of the original dataset as a list
#     """
#     if len(dataset) < subset_size:
#         raise Exception(f'The dataset to extract a subset from is too small: '
#                         f'{len(dataset)} < {subset_size}')
# 
#     # save random number generator state
#     rng_state = np.random.get_state()
# 
#     if seed is not None:
#         # extract a subset (for a given training set, the subset will always be identical).
#         np.random.seed(seed)
# 
#     subset = np.random.choice(dataset, subset_size, replace=False)
# 
#     if seed is not None:
#         # reset random number generator state, only if needed
#         np.random.set_state(rng_state)
# 
#     return list(subset)


import numpy as np
import pytest
from guacamol.utils.data import get_random_subset
def test_subset():
    dataset = list(np.random.rand(100))

    subset = get_random_subset(dataset, 10)

    for s in subset:
        assert s in dataset


def test_subset_if_dataset_too_small():
    dataset = list(np.random.rand(100))

    with pytest.raises(Exception):
        get_random_subset(dataset, 1000)


def test_subset_with_no_seed():
    dataset = list(np.random.rand(100))

    subset1 = get_random_subset(dataset, 10)
    subset2 = get_random_subset(dataset, 10)

    assert subset1 != subset2


def test_subset_with_random_seed():
    dataset = list(np.random.rand(100))

    subset1 = get_random_subset(dataset, 10, seed=33)
    subset2 = get_random_subset(dataset, 10, seed=33)

# Path: guacamol/utils/data.py
# def get_random_subset(dataset: List[Any], subset_size: int, seed: Optional[int] = None) -> List[Any]:
#     """
#     Get a random subset of some dataset.
# 
#     For reproducibility, the random number generator seed can be specified.
#     Nevertheless, the state of the random number generator is restored to avoid side effects.
# 
#     Args:
#         dataset: full set to select a subset from
#         subset_size: target size of the subset
#         seed: random number generator seed. Defaults to not setting the seed.
# 
#     Returns:
#         subset of the original dataset as a list
#     """
#     if len(dataset) < subset_size:
#         raise Exception(f'The dataset to extract a subset from is too small: '
#                         f'{len(dataset)} < {subset_size}')
# 
#     # save random number generator state
#     rng_state = np.random.get_state()
# 
#     if seed is not None:
#         # extract a subset (for a given training set, the subset will always be identical).
#         np.random.seed(seed)
# 
#     subset = np.random.choice(dataset, subset_size, replace=False)
# 
#     if seed is not None:
#         # reset random number generator state, only if needed
#         np.random.set_state(rng_state)
# 
#     return list(subset)


# Path: tests/utils/test_data.py
import numpy as np
import pytest
from guacamol.utils.data import get_random_subset

def test_subset():
    dataset = list(np.random.rand(100))

    subset = get_random_subset(dataset, 10)

    for s in subset:
        assert s in dataset


def test_subset_if_dataset_too_small():
    dataset = list(np.random.rand(100))

    with pytest.raises(Exception):
        get_random_subset(dataset, 1000)


def test_subset_with_no_seed():
    dataset = list(np.random.rand(100))

    subset1 = get_random_subset(dataset, 10)
    subset2 = get_random_subset(dataset, 10)

    assert subset1 != subset2


def test_subset_with_random_seed():
    dataset = list(np.random.rand(100))

    subset1 = get_random_subset(dataset, 10, seed=33)
    subset2 = get_random_subset(dataset, 10, seed=33)

    subset3 = get_random_subset(dataset, 10, seed=43)