qiskit/pulse/commands/pulse_decorators.py
def functional_pulse(func):
    """A decorator for generating SamplePulse from python callable.
    Args:
        func (callable): A function describing pulse envelope.
    Raises:
        PulseError: when invalid function is specified.
    """
    @functools.wraps(func)
    def to_pulse(duration, *args, name=None, **kwargs):
        """Return SamplePulse."""
        if isinstance(duration, int) and duration > 0:
            samples = func(duration, *args, **kwargs)
            samples = np.asarray(samples, dtype=np.complex128)
            return SamplePulse(samples=samples, name=name)
        raise PulseError('The first argument must be an integer value representing duration.')

    return to_pulse
def functional_pulse(func):
    """A decorator for generating SamplePulse from python callable.
    Args:
        func (callable): A function describing pulse envelope.
    Raises:
        PulseError: when invalid function is specified.
    """
    @functools.wraps(func)
    def to_pulse(duration, *args, name=None, **kwargs):
        """Return SamplePulse."""
        if isinstance(duration, int) and duration > 0:
            samples = func(duration, *args, **kwargs)
            samples = np.asarray(samples, dtype=np.complex128)
            return SamplePulse(samples=samples, name=name)
        raise PulseError('The first argument must be an integer value representing duration.')

    return to_pulse
def functional_pulse ( func ) : @ functools . wraps ( func ) def to_pulse ( duration , * args , name = None , * * kwargs ) : """Return SamplePulse.""" if isinstance ( duration , int ) and duration > 0 : samples = func ( duration , * args , * * kwargs ) samples = np . asarray ( samples , dtype = np . complex128 ) return SamplePulse ( samples = samples , name = name ) raise PulseError ( 'The first argument must be an integer value representing duration.' ) return to_pulse
A decorator for generating SamplePulse from python callable.
    Args:
        func (callable): A function describing pulse envelope.
    Raises:
        PulseError: when invalid function is specified.
A decorator for generating SamplePulse from python callable . Args : func ( callable ) : A function describing pulse envelope . Raises : PulseError : when invalid function is specified .