IPC bug fixes by StephenNneji · Pull Request #190 · RascalSoftware/python-RAT · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ratapi/controls.py
9 changes: 8 additions & 1 deletion ratapi/utils/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,14 @@ def fix_invalid_constraints(name: str, constrs: tuple[float, float], value: floa
if Path(custom_filepath).suffix != ".m":
custom_filepath += ".m"
model_name = Path(custom_filepath).stem
custom_file = ClassList([CustomFile(name=model_name, filename=custom_filepath, language=Languages.Matlab)])
# Assume the custom file is in the same directory as the mat file
custom_file = ClassList(
[
CustomFile(
name=model_name, filename=custom_filepath, language=Languages.Matlab, path=Path(filename).parent
)
]
)
layers = ClassList()
for contrast in contrasts:
contrast.model = [model_name]
Expand Down
3 changes: 2 additions & 1 deletion ratapi/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ def update_plot(self, data):
"""
if self.figure is not None:
self.figure.clf()

self.figure.tight_layout()
plot_ref_sld_helper(
data,
self.figure,
Expand All @@ -502,7 +504,6 @@ def update_plot(self, data):
show_legend=self.show_legend,
animated=True,
)
self.figure.tight_layout(pad=1)
self.figure.canvas.draw()
self.bg = self.figure.canvas.copy_from_bbox(self.figure.bbox)
for line in self.figure.axes[0].lines:
Expand Down
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6858,7 +6858,11 @@ def r1_monolayer():
),
custom_files=ratapi.ClassList(
ratapi.models.CustomFile(
name="Model_IIb", filename="Model_IIb.m", function_name="Model_IIb", language="matlab"
name="Model_IIb",
filename="Model_IIb.m",
function_name="Model_IIb",
language="matlab",
path=Path(__file__).parent / "test_data",
)
),
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ def test_initialise_IPC() -> None:
assert test_controls._IPCFilePath != ""
with open(test_controls._IPCFilePath, "rb") as f:
file_content = f.read()
assert file_content == b"0"
assert file_content == b"\x00"
os.remove(test_controls._IPCFilePath)


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


def test_sendStopEvent_empty_file() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_convert.py
Loading