# Buggy code
def __init__(
    self,
    *schedules,
    parameters: Optional[Dict[str, Union[float, complex]]] = None,
    name: Optional[str] = None,
):
    full_schedules = []
    parameterized = []
    parameters = parameters or []
    self.name = name or ""
    # partition schedules into callable and schedules
    for schedule in schedules:
        if isinstance(schedule, ParameterizedSchedule):
            parameterized.append(schedule)
            parameters += schedule.parameters
        elif callable(schedule):
            parameterized.append(schedule)
        elif isinstance(schedule, Schedule):
            full_schedules.append(schedule)
        else:
            raise PulseError("Input type: {0} not supported".format(type(schedule)))

    self._parameterized = tuple(parameterized)
    self._schedules = tuple(full_schedules)
    self._parameters = tuple(sorted(parameters))


# Traceback (PulseError)
---------------------------------------------------------------------------
PulseError                                Traceback (most recent call last)
<ipython-input-16-5eef41f492e0> in <module>
----> 1 control_xgate = cmd_def.get('u3', control, np.pi, 0, np.pi)

~/anaconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/cmd_def.py in get(self, cmd_name, qubits, *params, **kwparams)
134
135             if isinstance(schedule, ParameterizedSchedule):
--> 136                 return schedule.bind_parameters(*params, **kwparams)
137
138             return schedule.flatten()

~/anaconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/schedule.py in bind_parameters(self, *args, **kwargs)
414                 predefined = self.parameters
415             sub_params = {k: v for k, v in named_parameters.items() if k in predefined}
--> 416             schedules.append(param_sched(**sub_params))
417
418         # construct evaluated schedules

~/anaconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/schedule.py in __call__(self, *args, **kwargs)
424     def __call__(self, *args: List[Union[float, complex]],
425                  **kwargs: Dict[str, Union[float, complex]]) -> Schedule:
--> 426         return self.bind_parameters(*args, **kwargs)

~/anaconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/schedule.py in bind_parameters(self, *args, **kwargs)
414                 predefined = self.parameters
415             sub_params = {k: v for k, v in named_parameters.items() if k in predefined}
--> 416             schedules.append(param_sched(**sub_params))
417
418         # construct evaluated schedules

~/anaconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/qobj/converters/pulse_instruction.py in gen_fc_sched(*args, **kwargs)
346
347             def gen_fc_sched(*args, **kwargs):
--> 348                 phase = abs(phase_expr(*args, **kwargs))
349                 return commands.FrameChange(phase)(channel) << t0
350

~/anaconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/parser.py in __call__(self, *args, **kwargs)
134                 return PulseExpression(expr, self._partial_binding)
135             else:
--> 136                 raise PulseError('Parameters %s are not all bound.' % self.params)
137         return expr.body.n
138

PulseError: "Parameters ['P2'] are not all bound."

# Fixed code
def __init__(
    self,
    *schedules,
    parameters: Optional[Dict[str, Union[float, complex]]] = None,
    name: Optional[str] = None,
):
    full_schedules = []
    parameterized = []
    parameters = parameters or []
    self.name = name or ""
    # partition schedules into callable and schedules
    for schedule in schedules:
        if isinstance(schedule, ParameterizedSchedule):
            parameterized.append(schedule)
            parameters += schedule.parameters
        elif callable(schedule):
            parameterized.append(schedule)
        elif isinstance(schedule, Schedule):
            full_schedules.append(schedule)
        else:
            raise PulseError("Input type: {0} not supported".format(type(schedule)))

    self._parameterized = tuple(parameterized)
    self._schedules = tuple(full_schedules)
    self._parameters = tuple(sorted(set(parameters)))