# 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/base.py
# class Quantity(Parameter):
# 
#     """A :class:`.Parameter` associated with a unit."""
# 
#     def __init__(self, unit, fget=None, fset=None, fget_target=None, lower=None, upper=None,
#                  data=None, check=None, external_lower_getter=None, external_upper_getter=None,
#                  user_lower_getter=None, user_lower_setter=None, user_upper_getter=None,
#                  user_upper_setter=None, help=None):
#         """
#         *fget*, *fset*, *data*, *check* and *help* are identical to the
#         :class:`.Parameter` constructor arguments.
# 
#         *unit* is a Pint quantity. *lower* and *upper* denote soft limits
#         between the :class:`.Quantity` values can lie.
#         """
#         super(Quantity, self).__init__(fget=fget, fset=fset, fget_target=fget_target, data=data,
#                                        check=check, help=help)
#         self.unit = unit
# 
#         self.upper = upper
#         self.lower = lower
#         self.external_lower_getter = external_lower_getter
#         self.external_upper_getter = external_upper_getter
#         self.user_lower_getter = user_lower_getter
#         self.user_lower_setter = user_lower_setter
#         self.user_upper_getter = user_upper_getter
#         self.user_upper_setter = user_upper_setter
# 
#     def convert(self, value):
#         return value.to(self.unit)
# 
# Path: concert/devices/base.py
# class Device(Parameterizable):
# 
#     """
#     A :class:`.Device` provides locked access to a real-world device.
# 
#     It implements the context protocol to provide locking::
# 
#         async with device:
#             # device is locked
#             await device.set_parameter(1 * q.m)
#             ...
# 
#         # device is unlocked again
#     """
# 
#     def __init__(self):
#         # We have to create the lock early on because it will be accessed in
#         # any add_parameter calls, especially those in the Parameterizable base
#         # class
#         self._lock = asyncio.Lock()
#         super(Device, self).__init__()
# 
#     async def __aenter__(self):
#         await self._lock.acquire()
# 
#         return self
# 
#     async def __aexit__(self, exc_type, exc, tb):
#         self._lock.release()
# 
#     @background
#     async def emergency_stop(self):
#         """Emergency stop."""
#         await self._emergency_stop()
# 
#     async def _emergency_stop(self):
#         """Emergency stop implementation."""
#         pass
# 
# Path: concert/devices/motors/base.py
# class LinearMotor(_PositionMixin):
# 
#     """
#     One-dimensional linear motor.
# 
#     .. attribute:: position
# 
#         Position of the motor in length units.
#     """
# 
#     def __init__(self):
#         super(LinearMotor, self).__init__()
# 
#     async def _get_state(self):
#         raise NotImplementedError
# 
#     state = State(default='standby')
# 
#     position = Quantity(q.mm, help="Position",
#                         check=check(source=['hard-limit', 'standby'],
#                                     target=['hard-limit', 'standby']))


import asyncio
import numpy as np
from concert.coroutines.base import background
from concert.quantities import q
from concert.base import Quantity
from concert.devices.base import Device
from concert.devices.motors.base import LinearMotor
        """Set position (angular or translational) given by *vector* on *axes*."""
        coros = []
        for i, coordinate in enumerate(['x', 'y', 'z']):
            magnitude = vector[i].magnitude
            if not np.isnan(magnitude):
                if coordinate not in axes:
                    if magnitude != 0:
                        # Last chance is to specify the coordinate to be zero.
                        raise PositionerError('Cannot move in {} coordinate'.format(coordinate))
                else:
                    coro = axes[coordinate].set_position(vector[i])
                    coros.append(coro)

        await asyncio.gather(*coros)


class PositionerError(Exception):
    """Positioning exceptions"""
    pass


def _vectorize(scalar, coordinate):
    """
    Return a vector with the *scalar* in the correct place given by the
    *coordinate* as x, y or z.
    """
    vector = np.zeros(3, dtype=np.float)
    translate = dict(x=0, y=1, z=2)
    vector[translate[coordinate]] = scalar.magnitude


# 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/base.py
# class Quantity(Parameter):
# 
#     """A :class:`.Parameter` associated with a unit."""
# 
#     def __init__(self, unit, fget=None, fset=None, fget_target=None, lower=None, upper=None,
#                  data=None, check=None, external_lower_getter=None, external_upper_getter=None,
#                  user_lower_getter=None, user_lower_setter=None, user_upper_getter=None,
#                  user_upper_setter=None, help=None):
#         """
#         *fget*, *fset*, *data*, *check* and *help* are identical to the
#         :class:`.Parameter` constructor arguments.
# 
#         *unit* is a Pint quantity. *lower* and *upper* denote soft limits
#         between the :class:`.Quantity` values can lie.
#         """
#         super(Quantity, self).__init__(fget=fget, fset=fset, fget_target=fget_target, data=data,
#                                        check=check, help=help)
#         self.unit = unit
# 
#         self.upper = upper
#         self.lower = lower
#         self.external_lower_getter = external_lower_getter
#         self.external_upper_getter = external_upper_getter
#         self.user_lower_getter = user_lower_getter
#         self.user_lower_setter = user_lower_setter
#         self.user_upper_getter = user_upper_getter
#         self.user_upper_setter = user_upper_setter
# 
#     def convert(self, value):
#         return value.to(self.unit)
# 
# Path: concert/devices/base.py
# class Device(Parameterizable):
# 
#     """
#     A :class:`.Device` provides locked access to a real-world device.
# 
#     It implements the context protocol to provide locking::
# 
#         async with device:
#             # device is locked
#             await device.set_parameter(1 * q.m)
#             ...
# 
#         # device is unlocked again
#     """
# 
#     def __init__(self):
#         # We have to create the lock early on because it will be accessed in
#         # any add_parameter calls, especially those in the Parameterizable base
#         # class
#         self._lock = asyncio.Lock()
#         super(Device, self).__init__()
# 
#     async def __aenter__(self):
#         await self._lock.acquire()
# 
#         return self
# 
#     async def __aexit__(self, exc_type, exc, tb):
#         self._lock.release()
# 
#     @background
#     async def emergency_stop(self):
#         """Emergency stop."""
#         await self._emergency_stop()
# 
#     async def _emergency_stop(self):
#         """Emergency stop implementation."""
#         pass
# 
# Path: concert/devices/motors/base.py
# class LinearMotor(_PositionMixin):
# 
#     """
#     One-dimensional linear motor.
# 
#     .. attribute:: position
# 
#         Position of the motor in length units.
#     """
# 
#     def __init__(self):
#         super(LinearMotor, self).__init__()
# 
#     async def _get_state(self):
#         raise NotImplementedError
# 
#     state = State(default='standby')
# 
#     position = Quantity(q.mm, help="Position",
#                         check=check(source=['hard-limit', 'standby'],
#                                     target=['hard-limit', 'standby']))


# Path: concert/devices/positioners/base.py
import asyncio
import numpy as np
from concert.coroutines.base import background
from concert.quantities import q
from concert.base import Quantity
from concert.devices.base import Device
from concert.devices.motors.base import LinearMotor

        """Set position (angular or translational) given by *vector* on *axes*."""
        coros = []
        for i, coordinate in enumerate(['x', 'y', 'z']):
            magnitude = vector[i].magnitude
            if not np.isnan(magnitude):
                if coordinate not in axes:
                    if magnitude != 0:
                        # Last chance is to specify the coordinate to be zero.
                        raise PositionerError('Cannot move in {} coordinate'.format(coordinate))
                else:
                    coro = axes[coordinate].set_position(vector[i])
                    coros.append(coro)

        await asyncio.gather(*coros)


class PositionerError(Exception):
    """Positioning exceptions"""
    pass


def _vectorize(scalar, coordinate):
    """
    Return a vector with the *scalar* in the correct place given by the
    *coordinate* as x, y or z.
    """
    vector = np.zeros(3, dtype=np.float)
    translate = dict(x=0, y=1, z=2)
    vector[translate[coordinate]] = scalar.magnitude


    return q.Quantity(vector, scalar.units)