# Buggy code
def transpile_dag(
    dag,
    basis_gates=None,
    coupling_map=None,
    initial_layout=None,
    seed_mapper=None,
    pass_manager=None,
):
    """Transform a dag circuit into another dag circuit (transpile), through
    consecutive passes on the dag.

    Args:
        dag (DAGCircuit): dag circuit to transform via transpilation
        basis_gates (list[str]): list of basis gate names supported by the
            target. Default: ['u1','u2','u3','cx','id']
        coupling_map (list): A graph of coupling::

            [
             [control0(int), target0(int)],
             [control1(int), target1(int)],
            ]

            eg. [[0, 2], [1, 2], [1, 3], [3, 4]}

        initial_layout (Layout or None): A layout object
        seed_mapper (int): random seed_mapper for the swap mapper
        pass_manager (PassManager): pass manager instance for the transpilation process
            If None, a default set of passes are run.
            Otherwise, the passes defined in it will run.
            If contains no passes in it, no dag transformations occur.

    Returns:
        DAGCircuit: transformed dag
    """
    # TODO: `basis_gates` will be removed after we have the unroller pass.
    # TODO: `coupling_map`, `initial_layout`, `seed_mapper` removed after mapper pass.

    if basis_gates is None:
        basis_gates = ["u1", "u2", "u3", "cx", "id"]
    if isinstance(basis_gates, str):
        warnings.warn(
            "The parameter basis_gates is now a list of strings. "
            "For example, this basis ['u1','u2','u3','cx'] should be used "
            "instead of 'u1,u2,u3,cx'. The string format will be "
            "removed after 0.9",
            DeprecationWarning,
            2,
        )
        basis_gates = basis_gates.split(",")

    if pass_manager is None:
        # default set of passes

        # if a coupling map is given compile to the map
        if coupling_map:
            pass_manager = default_pass_manager(
                basis_gates,
                CouplingMap(coupling_map),
                initial_layout,
                seed_mapper=seed_mapper,
            )
        else:
            pass_manager = default_pass_manager_simulator(basis_gates)

    # run the passes specified by the pass manager
    # TODO return the property set too. See #1086
    name = dag.name
    dag = pass_manager.run_passes(dag)
    dag.name = name

    return dag


# Traceback (TypeError)
qobj = qk.compile(qc, backend=FakeTokyo())
/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/tools/compiler.py:50: DeprecationWarning: qiskit.compile() is deprecated and will be removed in Qiskit Terra 0.9. Please use qiskit.transpile() to transform circuits and qiskit.assemble_circuits() to produce qobj.
DeprecationWarning)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/tools/compiler.py", line 67, in compile
initial_layout, seed_mapper, pass_manager)
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/transpiler/transpiler.py", line 85, in transpile
'pass_manager': pass_manager})
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/tools/parallel.py", line 93, in parallel_map
return [task(values[0], *task_args, **task_kwargs)]
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/transpiler/transpiler.py", line 143, in _transpilation
pass_manager=pass_manager)
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/transpiler/transpiler.py", line 234, in transpile_dag
dag = pass_manager.run_passes(dag)
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/transpiler/passmanager.py", line 129, in run_passes
dag = self._do_pass(pass_, dag, passset.options)
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/transpiler/passmanager.py", line 169, in _do_pass
new_dag = pass_.run(dag)
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/transpiler/passes/optimize_1q_gates.py", line 62, in run
left_parameters = tuple([float(x) for x in left_parameters])
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/transpiler/passes/optimize_1q_gates.py", line 62, in <listcomp>
left_parameters = tuple([float(x) for x in left_parameters])
File "/Users/kevin.krsulichibm.com/q/qiskit-terra/lib/python3.5/site-packages/sympy/core/expr.py", line 256, in __float__
raise TypeError("can't convert expression to float")
TypeError: can't convert expression to float

# Fixed code
def transpile_dag(
    dag,
    basis_gates=None,
    coupling_map=None,
    initial_layout=None,
    skip_numeric_passes=None,
    seed_mapper=None,
    pass_manager=None,
):
    """Transform a dag circuit into another dag circuit (transpile), through
    consecutive passes on the dag.

    Args:
        dag (DAGCircuit): dag circuit to transform via transpilation
        basis_gates (list[str]): list of basis gate names supported by the
            target. Default: ['u1','u2','u3','cx','id']
        coupling_map (list): A graph of coupling::

            [
             [control0(int), target0(int)],
             [control1(int), target1(int)],
            ]

            eg. [[0, 2], [1, 2], [1, 3], [3, 4]}

        initial_layout (Layout or None): A layout object
        skip_numeric_passes (bool): If true, skip passes which require fixed parameter values
        seed_mapper (int): random seed_mapper for the swap mapper
        pass_manager (PassManager): pass manager instance for the transpilation process
            If None, a default set of passes are run.
            Otherwise, the passes defined in it will run.
            If contains no passes in it, no dag transformations occur.

    Returns:
        DAGCircuit: transformed dag
    """
    # TODO: `basis_gates` will be removed after we have the unroller pass.
    # TODO: `coupling_map`, `initial_layout`, `seed_mapper` removed after mapper pass.

    if basis_gates is None:
        basis_gates = ["u1", "u2", "u3", "cx", "id"]
    if isinstance(basis_gates, str):
        warnings.warn(
            "The parameter basis_gates is now a list of strings. "
            "For example, this basis ['u1','u2','u3','cx'] should be used "
            "instead of 'u1,u2,u3,cx'. The string format will be "
            "removed after 0.9",
            DeprecationWarning,
            2,
        )
        basis_gates = basis_gates.split(",")

    if pass_manager is None:
        # default set of passes

        # if a coupling map is given compile to the map
        if coupling_map:
            pass_manager = default_pass_manager(
                basis_gates,
                CouplingMap(coupling_map),
                initial_layout,
                skip_numeric_passes,
                seed_mapper=seed_mapper,
            )
        else:
            pass_manager = default_pass_manager_simulator(basis_gates)

    # run the passes specified by the pass manager
    # TODO return the property set too. See #1086
    name = dag.name
    dag = pass_manager.run_passes(dag)
    dag.name = name

    return dag