Skip to content

Commit 4432835

Browse files
ruff checks
1 parent 23affff commit 4432835

File tree

5 files changed

+29
-33
lines changed

5 files changed

+29
-33
lines changed

src/ibex_bluesky_core/devices/dae/_period_settings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from xml.etree.ElementTree import tostring
88

99
from bluesky.protocols import Locatable, Location, Movable
10-
from ophyd_async.core import AsyncStatus, StandardReadable, SignalRW
10+
from ophyd_async.core import AsyncStatus, SignalRW, StandardReadable
1111

1212
from ibex_bluesky_core.devices import (
1313
isis_epics_signal_rw,
@@ -116,7 +116,9 @@ def _convert_period_settings_to_xml(current_xml: str, value: DaePeriodSettingsDa
116116
return tostring(root, encoding="unicode")
117117

118118

119-
class DaePeriodSettings(StandardReadable, Locatable[DaePeriodSettingsData], Movable[DaePeriodSettingsData]):
119+
class DaePeriodSettings(
120+
StandardReadable, Locatable[DaePeriodSettingsData], Movable[DaePeriodSettingsData]
121+
):
120122
"""Subdevice for the DAE hardware period settings."""
121123

122124
def __init__(self, dae_prefix: str, name: str = "") -> None:

src/ibex_bluesky_core/plan_stubs/num_periods_wrapper.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""Wrap a plan with temporary modification to Periods Settings."""
22

3-
import copy
43
from collections.abc import Generator
54

65
import bluesky.plan_stubs as bps
76
import bluesky.preprocessors as bpp
87
from bluesky.utils import Msg
98
from ophyd_async.plan_stubs import ensure_connected
10-
from ibex_bluesky_core.devices.dae import DaePeriodSettings, Dae
9+
10+
from ibex_bluesky_core.devices.dae import Dae
1111

1212

1313
def with_num_periods(
@@ -25,7 +25,6 @@ def with_num_periods(
2525
number of periods afterwards.
2626
2727
"""
28-
2928
original_num_periods = None
3029

3130
def _inner() -> Generator[Msg, None, None]:

src/ibex_bluesky_core/plan_stubs/time_channels_wrapper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from bluesky.utils import Msg
88
from ophyd_async.plan_stubs import ensure_connected
99

10-
1110
from ibex_bluesky_core.devices.dae import Dae, DaeTCBSettingsData
1211

1312

tests/devices/test_dae.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040
from ibex_bluesky_core.devices.dae._period_settings import _convert_period_settings_to_xml
4141
from ibex_bluesky_core.devices.dae._tcb_settings import _convert_tcb_settings_to_xml
42-
from tests.conftest import MOCK_PREFIX, dae
42+
from tests.conftest import MOCK_PREFIX
4343
from tests.devices.dae_testing_data import (
4444
dae_settings_template,
4545
initial_dae_settings,
@@ -1016,5 +1016,3 @@ async def test_if_tof_edges_has_no_units_then_read_spec_dataarray_gives_error(
10161016

10171017
def test_dae_repr():
10181018
assert repr(Dae(prefix="foo", name="bar")) == "Dae(name=bar, prefix=foo)"
1019-
1020-

tests/test_plan_stubs.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@
66

77
import matplotlib.pyplot as plt
88
import pytest
9-
from bluesky import RunEngine, plan_stubs as bps
9+
from bluesky import RunEngine
10+
from bluesky import plan_stubs as bps
1011
from bluesky.utils import Msg
1112
from ophyd_async.epics.motor import UseSetMode
1213
from ophyd_async.plan_stubs import ensure_connected
1314
from ophyd_async.testing import get_mock_put, set_mock_value
1415

1516
from ibex_bluesky_core.devices import NoYesChoice, compress_and_hex, dehex_and_decompress
1617
from ibex_bluesky_core.devices.block import BlockMot
17-
from ibex_bluesky_core.devices.dae import Dae, TCBCalculationMethod, TCBTimeUnit, DaeTCBSettingsData, DaeSettingsData
18+
from ibex_bluesky_core.devices.dae import (
19+
Dae,
20+
DaeSettingsData,
21+
DaeTCBSettingsData,
22+
TCBCalculationMethod,
23+
TCBTimeUnit,
24+
)
1825
from ibex_bluesky_core.devices.dae._tcb_settings import _convert_xml_to_tcb_settings
1926
from ibex_bluesky_core.devices.reflectometry import ReflParameter
2027
from ibex_bluesky_core.plan_stubs import (
@@ -29,7 +36,7 @@
2936
from ibex_bluesky_core.plan_stubs.num_periods_wrapper import with_num_periods
3037
from ibex_bluesky_core.plan_stubs.time_channels_wrapper import with_time_channels
3138
from ibex_bluesky_core.run_engine._msg_handlers import call_sync_handler
32-
from tests.devices.dae_testing_data import tcb_settings_template, dae_settings_template
39+
from tests.devices.dae_testing_data import dae_settings_template, tcb_settings_template
3340

3441

3542
def test_call_sync_returns_result(RE):
@@ -210,15 +217,13 @@ def test_num_periods_wrapper(dae: Dae, RE: RunEngine):
210217
assert mock_set_calls[1].args[0] == original_settings
211218

212219

213-
async def test_time_channels_wrapper(dae: Dae, RE: RunEngine):
220+
def test_time_channels_wrapper(dae: Dae, RE: RunEngine):
214221
expected_tcb_file = "C:\\tcb.dat"
215222
expected_calc_method = TCBCalculationMethod.SPECIFY_PARAMETERS
216223
expected_time_unit = TCBTimeUnit.MICROSECONDS
217224

218-
219225
modified_settings = DaeTCBSettingsData(time_unit=TCBTimeUnit.NANOSECONDS)
220226

221-
222227
original_tcb_settings = tcb_settings_template.format(
223228
tcb_file=expected_tcb_file,
224229
time_units=expected_time_unit.value,
@@ -345,7 +350,6 @@ async def test_time_channels_wrapper(dae: Dae, RE: RunEngine):
345350
tr6_steps_5=1,
346351
)
347352

348-
349353
modified_raw_tcb_settings = tcb_settings_template.format(
350354
tcb_file=expected_tcb_file,
351355
time_units=TCBTimeUnit.NANOSECONDS.value,
@@ -472,27 +476,27 @@ async def test_time_channels_wrapper(dae: Dae, RE: RunEngine):
472476
tr6_steps_5=1,
473477
)
474478

475-
set_mock_value(dae.tcb_settings._raw_tcb_settings, compress_and_hex(original_tcb_settings).decode())
479+
set_mock_value(
480+
dae.tcb_settings._raw_tcb_settings, compress_and_hex(original_tcb_settings).decode()
481+
)
476482

477483
with patch("ibex_bluesky_core.plan_stubs.time_channels_wrapper.ensure_connected"):
478-
RE(
479-
with_time_channels(
480-
bps.null(),
481-
dae=dae,
482-
new_tcb_settings=modified_settings
483-
)
484-
)
484+
RE(with_time_channels(bps.null(), dae=dae, new_tcb_settings=modified_settings))
485485

486486
mock_set_calls = get_mock_put(dae.tcb_settings._raw_tcb_settings).call_args_list
487487

488488
# Note for these two assertions that you can't compare XML directly as order isn't guaranteed,
489489
# so convert to the dataclass instead.
490490

491491
# assert that modified settings are set
492-
assert _convert_xml_to_tcb_settings(modified_raw_tcb_settings) == _convert_xml_to_tcb_settings(dehex_and_decompress(mock_set_calls[0].args[0]).decode())
492+
assert _convert_xml_to_tcb_settings(modified_raw_tcb_settings) == _convert_xml_to_tcb_settings(
493+
dehex_and_decompress(mock_set_calls[0].args[0]).decode()
494+
)
493495

494496
# assert that the original settings are restored
495-
assert _convert_xml_to_tcb_settings(original_tcb_settings) == _convert_xml_to_tcb_settings(dehex_and_decompress(mock_set_calls[1].args[0]).decode())
497+
assert _convert_xml_to_tcb_settings(original_tcb_settings) == _convert_xml_to_tcb_settings(
498+
dehex_and_decompress(mock_set_calls[1].args[0]).decode()
499+
)
496500

497501

498502
def test_dae_table_wrapper(dae: Dae, RE: RunEngine):
@@ -553,13 +557,7 @@ def test_dae_table_wrapper(dae: Dae, RE: RunEngine):
553557
set_mock_value(dae.dae_settings._raw_dae_settings, original_settings)
554558

555559
with patch("ibex_bluesky_core.plan_stubs.dae_table_wrapper.ensure_connected"):
556-
RE(
557-
with_dae_tables(
558-
bps.null(),
559-
dae=dae,
560-
new_settings=modified_settings
561-
)
562-
)
560+
RE(with_dae_tables(bps.null(), dae=dae, new_settings=modified_settings))
563561

564562
mock_set_calls = get_mock_put(dae.dae_settings._raw_dae_settings).call_args_list
565563

0 commit comments

Comments
 (0)