Skip to content

Commit

Permalink
Modify data import method to work with py 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
fjclark committed Dec 17, 2023
1 parent dcea698 commit b6118c6
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions deea/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,26 @@
"""

import tempfile
from importlib import resources
from pathlib import Path

import numpy as np
import pytest


@pytest.fixture(scope="session")
def example_timeseries():
timeseries_bytes = (
resources.files("deea.data").joinpath("example_timeseries.npy").read_bytes()
)
with tempfile.NamedTemporaryFile(delete=True) as tmp:
tmp.write(timeseries_bytes)
tmp.seek(0)
timeseries = np.load(tmp.name)
yield timeseries
# This is not nice, but the suggested setuptools approach does not work for python
# 3.9 (worked fine for 3.12).
timeseries_path = Path(__file__).parent.parent / "data" / "example_timeseries.npy"
yield np.load(timeseries_path)


@pytest.fixture(scope="session")
def example_times():
times_bytes = (
resources.files("deea.data").joinpath("example_times.npy").read_bytes()
)
with tempfile.NamedTemporaryFile(delete=True) as tmp:
tmp.write(times_bytes)
tmp.seek(0)
times = np.load(tmp.name)
yield times
# This is not nice, but the suggested setuptools approach does not work for python
# 3.9 (worked fine for 3.12).
times_path = Path(__file__).parent.parent / "data" / "example_times.npy"
yield np.load(times_path)


# Generate 5 runs of 1000 samples of Gaussian noise.
Expand Down

0 comments on commit b6118c6

Please sign in to comment.