Skip to content

Commit

Permalink
Try to shorten tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Jan 31, 2025
1 parent 606ca19 commit 3d4fe17
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/ophyd_async/sim/_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ async def set(self, value: float):
"""
Asynchronously move the motor to a new position.
"""
start = time.time()
new_position = value
# Make sure any existing move tasks are stopped
await self.stop()
Expand Down Expand Up @@ -97,7 +96,6 @@ async def set(self, value: float):
name=self.name,
unit=units,
)
print("Move took", time.time() - start)
if not self._set_success:
raise RuntimeError("Motor was stopped")

Expand Down
2 changes: 0 additions & 2 deletions src/ophyd_async/sim/_point_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ async def _update_values(self, acquire_time: float):

@AsyncStatus.wrap
async def trigger(self):
start = time.time()
for setter in self._value_signals.values():
setter(0)
await self._update_values(await self.acquire_time.get_value())
print("Trigger took", time.time() - start)
6 changes: 5 additions & 1 deletion tests/test_tutorials.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib
import os
import re
import time
from pathlib import Path
Expand Down Expand Up @@ -29,6 +30,9 @@ def expected_scan_output():

@pytest.mark.parametrize("module", ["ophyd_async.sim", "ophyd_async.epics.demo"])
def test_implementing_devices(module, capsys, expected_scan_output):
# We want the text output of the best effort callback, but the plotting takes
# too much time for CI, even if headless, so disable it
os.environ.pop("MPLBACKEND", None)
with patch("bluesky.run_engine.autoawait_in_bluesky_event_loop") as autoawait:
main = importlib.import_module(f"{module}.__main__")
autoawait.assert_called_once_with()
Expand All @@ -37,7 +41,7 @@ def test_implementing_devices(module, capsys, expected_scan_output):
RE(main.bps.mv(motor.velocity, 1000))
start = time.monotonic()
RE(main.bp.grid_scan([main.pdet], main.stage.x, 1, 2, 3, main.stage.y, 2, 3, 3))
assert time.monotonic() - start == pytest.approx(20.0, abs=1.0)
assert time.monotonic() - start == pytest.approx(2.5, abs=2.0)
captured = capsys.readouterr()
assert captured.err == ""
assert SCAN_LINE.findall(captured.out) == expected_scan_output

0 comments on commit 3d4fe17

Please sign in to comment.