Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Apr 10, 2024
1 parent 7039b8d commit adcf3bf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
7 changes: 2 additions & 5 deletions src/ophyd_async/epics/areadetector/aravis.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from typing import get_args

from bluesky.protocols import HasHints, Hints
from ophyd_async.core import (
DirectoryProvider,
StandardDetector,
TriggerInfo,
)

from ophyd_async.core import DirectoryProvider, StandardDetector, TriggerInfo
from ophyd_async.epics.areadetector.controllers.aravis_controller import (
ADAravisController,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
ADAravisTriggerMode,
ADAravisTriggerSource,
)
from ophyd_async.epics.areadetector.utils import (
ImageMode,
stop_busy_record,
)
from ophyd_async.epics.areadetector.utils import ImageMode, stop_busy_record


class ADAravisController(DetectorControl):
Expand Down
21 changes: 12 additions & 9 deletions src/ophyd_async/epics/areadetector/drivers/aravis_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from typing import Callable, Dict, Tuple

from ophyd_async.epics.areadetector.drivers import ADBase
from ophyd_async.epics.areadetector.utils import (
ad_r,
ad_rw,
)
from ophyd_async.epics.areadetector.utils import ad_r, ad_rw


class ADAravisTriggerMode(str, Enum):
Expand All @@ -33,7 +30,9 @@ class ADAravisTriggerSource(str, Enum):
line_4 = "Line4"


def _reverse_lookup(model_deadtimes: Dict[float, Tuple[str, ...]]) -> Callable[[str], float]:
def _reverse_lookup(
model_deadtimes: Dict[float, Tuple[str, ...]],
) -> Callable[[str], float]:
def inner(pixel_format: str) -> float:
for deadtime, pixel_formats in model_deadtimes.items():
if pixel_format in pixel_formats:
Expand All @@ -44,7 +43,8 @@ def inner(pixel_format: str) -> float:


_deadtimes: Dict[str, Callable[[str], float]] = {
# cite: https://cdn.alliedvision.com/fileadmin/content/documents/products/cameras/Manta/techman/Manta_TechMan.pdf retrieved 2024-04-05
# cite: https://cdn.alliedvision.com/fileadmin/content/documents/products/cameras/Manta/techman/Manta_TechMan.pdf # noqa: E501
# retrieved 2024-04-05
"Manta G-125": lambda _: 63e-6,
"Manta G-145": lambda _: 106e-6,
"Manta G-235": _reverse_lookup(
Expand Down Expand Up @@ -87,9 +87,11 @@ def inner(pixel_format: str) -> float:
1961e-6: ("RGB8Packed", "BGR8Packed", "YUV444Packed"),
}
),
# cite: https://cdn.alliedvision.com/fileadmin/content/documents/products/cameras/various/appnote/GigE/GigE-Cameras_AppNote_PIV-Min-Time-Between-Exposures.pdf retrieved 2024-04-05
# cite: https://cdn.alliedvision.com/fileadmin/content/documents/products/cameras/various/appnote/GigE/GigE-Cameras_AppNote_PIV-Min-Time-Between-Exposures.pdf # noqa: E501
# retrieved 2024-04-05
"Manta G-609": lambda _: 47e-6,
# cite: https://cdn.alliedvision.com/fileadmin/content/documents/products/cameras/Mako/techman/Mako_TechMan_en.pdf retrieved 2024-04-05
# cite: https://cdn.alliedvision.com/fileadmin/content/documents/products/cameras/Mako/techman/Mako_TechMan_en.pdf # noqa: E501
# retrieved 2024-04-05
"Mako G-040": _reverse_lookup(
{
101e-6: (
Expand Down Expand Up @@ -138,8 +140,9 @@ def inner(pixel_format: str) -> float:
class ADAravisDriver(ADBase):
# If instantiating a new instance, ensure it is supported in the _deadtimes dict
"""Generic Driver supporting the Manta and Mako drivers.
Requires driver firmware up to date such that the Model_RBV is of the form "^(Mako|Manta) (model)$"
Fetches deadtime prior to use in a Streaming scan.
Requires driver firmware up to date:
Such that the Model_RBV is of the form "^(Mako|Manta) (model)$"
"""

def __init__(self, prefix: str, name: str = "") -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ async def inner_coroutine():

return inner_coroutine


@pytest.fixture
def static_directory_provider(tmp_path: Path):
return StaticDirectoryProvider(directory_path=tmp_path)
11 changes: 7 additions & 4 deletions tests/epics/areadetector/test_aravis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from bluesky.run_engine import RunEngine

from ophyd_async.core import (
DetectorTrigger,
DeviceCollector,
Expand Down Expand Up @@ -121,7 +122,8 @@ def test_gpio_pin_limited(adaravis: ADAravisDetector):
with pytest.raises(
ValueError,
match=re.escape(
"ADAravisDetector only supports the following GPIO indices: (1, 2, 3, 4) but was asked to use 55"
"ADAravisDetector only supports the following GPIO indices: (1, 2, 3, 4) "
"but was asked to use 55"
),
):
adaravis.set_external_trigger_gpio(55) # type: ignore
Expand All @@ -141,6 +143,7 @@ async def test_unsupported_trigger_excepts(adaravis: ADAravisDetector):
):
await adaravis.prepare(TriggerInfo(1, DetectorTrigger.variable_gate, 1, 1))


async def test_unsupported_model_excepts(adaravis: ADAravisDetector):
set_sim_value(adaravis._controller._drv.model, "foo")
set_sim_value(adaravis._controller._drv.pixel_format, "bar")
Expand All @@ -150,8 +153,8 @@ async def test_unsupported_model_excepts(adaravis: ADAravisDetector):
match=r"Detector .* needs at least nans deadtime, but trigger logic provides",
):
await adaravis.prepare(TriggerInfo(1, DetectorTrigger.variable_gate, 1, 1))


async def test_unsupported_pixel_format_excepts(adaravis: ADAravisDetector):
set_sim_value(adaravis._controller._drv.model, "Manta G-235")
set_sim_value(adaravis._controller._drv.pixel_format, "bar")
Expand All @@ -160,4 +163,4 @@ async def test_unsupported_pixel_format_excepts(adaravis: ADAravisDetector):
AssertionError,
match=r"Detector .* needs at least nans deadtime, but trigger logic provides",
):
await adaravis.prepare(TriggerInfo(1, DetectorTrigger.variable_gate, 1, 1))
await adaravis.prepare(TriggerInfo(1, DetectorTrigger.variable_gate, 1, 1))

0 comments on commit adcf3bf

Please sign in to comment.