Skip to content

Commit

Permalink
change acutator data uses to fixure
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Fiddy committed Jan 7, 2025
1 parent 787e607 commit cd89723
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from typing import Any

import numpy as np
import pandas as pd
import pytest

Expand Down Expand Up @@ -147,3 +148,13 @@ def raw_data_pivoted() -> pd.DataFrame:
columns=data.split("\n")[0].split(","),
) # type: ignore
return df.apply(pd.to_numeric, errors="coerce") # type: ignore


@pytest.fixture
def actuator_data(
request: tuple[str, str],
) -> tuple[np.typing.NDArray[np.float64], np.typing.NDArray[np.float64]]:
input_path, output_path = request.param
data = np.loadtxt(input_path, delimiter=",")
expected_output = np.loadtxt(output_path, delimiter=",")
return data, expected_output
10 changes: 6 additions & 4 deletions tests/script_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@


@pytest.mark.parametrize(
["input_path", "output_path"],
"actuator_data",
[
["tests/data/8_actuator_data.txt", "tests/data/8_actuator_output.txt"],
["tests/data/16_actuator_data.txt", "tests/data/16_actuator_output.txt"],
],
indirect=True,
)
def test_find_voltages_correct_output(input_path: str, output_path: str):
data = np.loadtxt(input_path, delimiter=",")
def test_find_voltages_correct_output(
actuator_data: tuple[np.typing.NDArray[np.float64], np.typing.NDArray[np.float64]],
):
data, expected_output = actuator_data
v = -100
expected_output = np.loadtxt(output_path, delimiter=",")
np.testing.assert_almost_equal(
find_voltages(data, v, baseline_voltage_scan=-1), expected_output
)
Expand Down

0 comments on commit cd89723

Please sign in to comment.