Commit 90f996df authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Axis to implement Scannable interface

parent 2d2f96f6
...@@ -11,6 +11,7 @@ Axis related classes (:class:`~bliss.common.axis.Axis`, \ ...@@ -11,6 +11,7 @@ Axis related classes (:class:`~bliss.common.axis.Axis`, \
and :class:`~bliss.common.axis.GroupMove`) and :class:`~bliss.common.axis.GroupMove`)
""" """
from bliss import global_map from bliss import global_map
from bliss.common.protocols import Scannable
from bliss.common.cleanup import capture_exceptions from bliss.common.cleanup import capture_exceptions
from bliss.common.motor_config import MotorConfig from bliss.common.motor_config import MotorConfig
from bliss.common.motor_settings import AxisSettings from bliss.common.motor_settings import AxisSettings
...@@ -652,7 +653,7 @@ def lazy_init(func): ...@@ -652,7 +653,7 @@ def lazy_init(func):
@with_custom_members @with_custom_members
class Axis: class Axis(Scannable):
""" """
Bliss motor axis Bliss motor axis
......
...@@ -99,7 +99,7 @@ class Scannable(ABC): ...@@ -99,7 +99,7 @@ class Scannable(ABC):
def move(self, target_position): def move(self, target_position):
""" """
This should This should move to target_position
""" """
raise NotImplementedError raise NotImplementedError
......
...@@ -11,7 +11,6 @@ from bliss.common.counter import Counter ...@@ -11,7 +11,6 @@ from bliss.common.counter import Counter
from typing import Union, Tuple, List, Sequence from typing import Union, Tuple, List, Sequence
from bliss.common.protocols import Scannable, CounterContainer, IterableNamespace from bliss.common.protocols import Scannable, CounterContainer, IterableNamespace
from bliss.common.measurementgroup import MeasurementGroup from bliss.common.measurementgroup import MeasurementGroup
from bliss.common.axis import Axis
######### types for typeguard ######### ######### types for typeguard #########
_int = numbers.Integral _int = numbers.Integral
...@@ -23,9 +22,7 @@ _countables = Union[ ...@@ -23,9 +22,7 @@ _countables = Union[
_float_or_countables = Union[ _float_or_countables = Union[
numbers.Real, IterableNamespace, Counter, MeasurementGroup, CounterContainer, Tuple numbers.Real, IterableNamespace, Counter, MeasurementGroup, CounterContainer, Tuple
] ]
_scannable = Union[Axis, Scannable] _scannable = Scannable
# Axis is included explicitly in _scannable as the Scannable protocol evaluates
# all attributes that are part of the protocol during type checking. (py 3.7)
_scannable_or_name = Union[_scannable, str] _scannable_or_name = Union[_scannable, str]
_scannable_start_stop_list = Sequence[Tuple[_scannable, _float, _float]] _scannable_start_stop_list = Sequence[Tuple[_scannable, _float, _float]]
_scannable_start_stop_intervals_list = Sequence[Tuple[_scannable, _float, _float, _int]] _scannable_start_stop_intervals_list = Sequence[Tuple[_scannable, _float, _float, _int]]
......
...@@ -605,7 +605,7 @@ def test_typeguardTypeError_to_hint(): ...@@ -605,7 +605,7 @@ def test_typeguardTypeError_to_hint():
scans.ascan(1, 2, 3, 4, 5) scans.ascan(1, 2, 3, 4, 5)
assert ( assert (
str(e.value) str(e.value)
== 'Intended Usage: ascan(motor, start, stop, intervals, count_time, counter_args) Hint: type of argument "motor" must be one of (Axis, Scannable); got int instead' == 'Intended Usage: ascan(motor, start, stop, intervals, count_time, counter_args) Hint: type of argument "motor" must be bliss.common.protocols.Scannable; got int instead'
) )
import typeguard import typeguard
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment