forked from angelolab/ark-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
29 lines (23 loc) · 822 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
from pathlib import Path
from typing import Generator, Iterator, Union
import numpy as np
import pytest
@pytest.fixture(scope="session")
def dataset_cache_dir() -> Iterator[Union[str, None]]:
# Change cache directory if running on CI
if os.environ.get("CI", None):
cache_dir = (Path(os.environ.get("GITHUB_WORKSPACE")) / "data" / "cache").resolve()
else:
cache_dir = None
yield cache_dir
@pytest.fixture(scope="session")
def rng() -> Generator[np.random.Generator, None, None]:
"""
Create a new Random Number Generator for tests which require randomized data.
Yields:
Generator[np.random.Generator, None, None]: The generator used for creating randomized
numbers.
"""
rng: np.random.Generator = np.random.default_rng(12345)
yield rng