Skip to content

Commit b16ca9f

Browse files
committed
tests and ruff
1 parent 1ea8af1 commit b16ca9f

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

ratapi/utils/convert.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,14 @@ def fix_invalid_constraints(name: str, constrs: tuple[float, float], value: floa
291291
if Path(custom_filepath).suffix != ".m":
292292
custom_filepath += ".m"
293293
model_name = Path(custom_filepath).stem
294-
custom_file = ClassList([CustomFile(name=model_name, filename=custom_filepath, language=Languages.Matlab)])
294+
# Assume the custom file is in the same directory as the mat file
295+
custom_file = ClassList(
296+
[
297+
CustomFile(
298+
name=model_name, filename=custom_filepath, language=Languages.Matlab, path=Path(filename).parent
299+
)
300+
]
301+
)
295302
layers = ClassList()
296303
for contrast in contrasts:
297304
contrast.model = [model_name]

ratapi/utils/plotting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def update_plot(self, data):
492492
"""
493493
if self.figure is not None:
494494
self.figure.clf()
495-
495+
496496
self.figure.tight_layout()
497497
plot_ref_sld_helper(
498498
data,

tests/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6858,7 +6858,11 @@ def r1_monolayer():
68586858
),
68596859
custom_files=ratapi.ClassList(
68606860
ratapi.models.CustomFile(
6861-
name="Model_IIb", filename="Model_IIb.m", function_name="Model_IIb", language="matlab"
6861+
name="Model_IIb",
6862+
filename="Model_IIb.m",
6863+
function_name="Model_IIb",
6864+
language="matlab",
6865+
path=Path(__file__).parent / "test_data",
68626866
)
68636867
),
68646868
)

tests/test_controls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ def test_initialise_IPC() -> None:
891891
assert test_controls._IPCFilePath != ""
892892
with open(test_controls._IPCFilePath, "rb") as f:
893893
file_content = f.read()
894-
assert file_content == b"0"
894+
assert file_content == b"\x00"
895895
os.remove(test_controls._IPCFilePath)
896896

897897

@@ -900,7 +900,7 @@ def test_sendStopEvent(IPC_controls) -> None:
900900
IPC_controls.sendStopEvent()
901901
with open(IPC_controls._IPCFilePath, "rb") as f:
902902
file_content = f.read()
903-
assert file_content == b"1"
903+
assert file_content == b"\x01"
904904

905905

906906
def test_sendStopEvent_empty_file() -> None:

tests/test_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def mock_load(ignored_filename, **ignored_settings):
9393

9494
monkeypatch.setattr("ratapi.utils.convert.loadmat", mock_load, raising=True)
9595

96-
converted_project = r1_to_project(project)
96+
converted_project = r1_to_project(pathlib.Path(__file__).parent / "test_data" / project)
9797

9898
for class_list in ratapi.project.class_lists:
9999
assert getattr(converted_project, class_list) == getattr(original_project, class_list)

0 commit comments

Comments
 (0)