# Path: concert/coroutines/base.py
# def background(coroutine):
#     """Same as :func:`.start`, just meant to be used as a decorator."""
#     @functools.wraps(coroutine)
#     def inner(*args, **kwargs):
#         return start(coroutine(*args, **kwargs))
# 
#     return inner
# 
# Path: concert/quantities.py

# 
# Path: concert/devices/positioners/base.py
# INF_VECTOR = np.array((np.inf, np.inf, np.inf))
# class Axis(object):
# class Positioner(Device):
# class PositionerError(Exception):
#     def __init__(self, coordinate, motor, direction=1, position=None):
#     async def get_position(self):
#     async def set_position(self, position):
#     def __init__(self, axes, position=None):
#     async def move(self, position):
#     async def rotate(self, angles):
#     async def right(self, value):
#     async def left(self, value):
#     async def up(self, value):
#     async def down(self, value):
#     async def forward(self, value):
#     async def back(self, value):
#     async def _get_position(self):
#     async def _set_position(self, position):
#     async def _get_orientation(self):
#     async def _set_orientation(self, angles):
#     async def _get_vector(self, axes):
#     async def _set_vector(self, vector, axes):
# def _vectorize(scalar, coordinate):


import numpy as np
from concert.coroutines.base import background
from concert.quantities import q
from concert.devices.positioners import base
"""
Imaging positioner which enables us to move around by specyfying distances
in the number of pixels.
"""


class Positioner(base.Positioner):

    """
    A positioner which takes into account a detector with some pixel size.
    This way the user can specify the movement in pixels.
    """

    def __init__(self, axes, detector, position=None):
        super(Positioner, self).__init__(axes, position=position)
        self.detector = detector

    @background
    async def move(self, position):
        """Move by specified *position* which can be given in meters or pixels."""
        # Is there a better way to check units?
        if str(position.units) == 'pixel':
            mag = position.magnitude
            if mag[-1] != 0 and not np.isnan(mag[-1]):

# Path: concert/coroutines/base.py
# def background(coroutine):
#     """Same as :func:`.start`, just meant to be used as a decorator."""
#     @functools.wraps(coroutine)
#     def inner(*args, **kwargs):
#         return start(coroutine(*args, **kwargs))
# 
#     return inner
# 
# Path: concert/quantities.py

# 
# Path: concert/devices/positioners/base.py
# INF_VECTOR = np.array((np.inf, np.inf, np.inf))
# class Axis(object):
# class Positioner(Device):
# class PositionerError(Exception):
#     def __init__(self, coordinate, motor, direction=1, position=None):
#     async def get_position(self):
#     async def set_position(self, position):
#     def __init__(self, axes, position=None):
#     async def move(self, position):
#     async def rotate(self, angles):
#     async def right(self, value):
#     async def left(self, value):
#     async def up(self, value):
#     async def down(self, value):
#     async def forward(self, value):
#     async def back(self, value):
#     async def _get_position(self):
#     async def _set_position(self, position):
#     async def _get_orientation(self):
#     async def _set_orientation(self, angles):
#     async def _get_vector(self, axes):
#     async def _set_vector(self, vector, axes):
# def _vectorize(scalar, coordinate):


# Path: concert/devices/positioners/imaging.py
import numpy as np
from concert.coroutines.base import background
from concert.quantities import q
from concert.devices.positioners import base

"""
Imaging positioner which enables us to move around by specyfying distances
in the number of pixels.
"""


class Positioner(base.Positioner):

    """
    A positioner which takes into account a detector with some pixel size.
    This way the user can specify the movement in pixels.
    """

    def __init__(self, axes, detector, position=None):
        super(Positioner, self).__init__(axes, position=position)
        self.detector = detector

    @background
    async def move(self, position):
        """Move by specified *position* which can be given in meters or pixels."""
        # Is there a better way to check units?
        if str(position.units) == 'pixel':
            mag = position.magnitude
            if mag[-1] != 0 and not np.isnan(mag[-1]):

                raise base.PositionerError('Cannot set \'z\' coordinate position in pixels.')