# Buggy code
def default_pass_manager(basis_gates, coupling_map, initial_layout, seed_mapper):
    """
    The default pass manager that maps to the coupling map.

    Args:
        basis_gates (list[str]): list of basis gate names supported by the
            target. Default: ['u1','u2','u3','cx','id']
        initial_layout (Layout or None): If None, trivial layout will be chosen.
        coupling_map (CouplingMap): coupling map (perhaps custom) to target
            in mapping.
        seed_mapper (int or None): random seed for the swap_mapper.

    Returns:
        PassManager: A pass manager to map and optimize.
    """
    pass_manager = PassManager()
    pass_manager.property_set["layout"] = initial_layout

    pass_manager.append(Unroller(basis_gates))

    # Use the trivial layout if no layouto is found
    pass_manager.append(
        TrivialLayout(coupling_map),
        condition=lambda property_set: not property_set["layout"],
    )

    # if the circuit and layout already satisfy the coupling_constraints, use that layout
    # otherwise layout on the most densely connected physical qubit subset
    pass_manager.append(CheckMap(coupling_map))
    pass_manager.append(
        DenseLayout(coupling_map),
        condition=lambda property_set: not property_set["is_swap_mapped"],
    )

    # Extend and enlarge the the dag/layout with ancillas using the full coupling map
    pass_manager.append(ExtendLayout(coupling_map))
    pass_manager.append(EnlargeWithAncilla())

    # Swap mapper
    pass_manager.append(LegacySwap(coupling_map, trials=20, seed=seed_mapper))

    # Expand swaps
    pass_manager.append(Decompose(SwapGate))

    # Change CX directions
    pass_manager.append(CXDirection(coupling_map))

    # Unroll to the basis
    pass_manager.append(Unroller(["u1", "u2", "u3", "id", "cx"]))

    # Simplify single qubit gates and CXs
    pass_manager.append(
        [Optimize1qGates(), CXCancellation(), Depth(), FixedPoint("depth")],
        do_while=lambda property_set: not property_set["depth_fixed_point"],
    )
    return pass_manager


# 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 default_pass_manager(
    basis_gates, coupling_map, initial_layout, skip_numeric_passes, seed_mapper
):
    """
    The default pass manager that maps to the coupling map.

    Args:
        basis_gates (list[str]): list of basis gate names supported by the
            target. Default: ['u1','u2','u3','cx','id']
        initial_layout (Layout or None): If None, trivial layout will be chosen.
        skip_numeric_passes (bool): If true, skip passes which require fixed parameter values
        coupling_map (CouplingMap): coupling map (perhaps custom) to target
            in mapping.
        seed_mapper (int or None): random seed for the swap_mapper.

    Returns:
        PassManager: A pass manager to map and optimize.
    """
    pass_manager = PassManager()
    pass_manager.property_set["layout"] = initial_layout

    pass_manager.append(Unroller(basis_gates))

    # Use the trivial layout if no layouto is found
    pass_manager.append(
        TrivialLayout(coupling_map),
        condition=lambda property_set: not property_set["layout"],
    )

    # if the circuit and layout already satisfy the coupling_constraints, use that layout
    # otherwise layout on the most densely connected physical qubit subset
    pass_manager.append(CheckMap(coupling_map))
    pass_manager.append(
        DenseLayout(coupling_map),
        condition=lambda property_set: not property_set["is_swap_mapped"],
    )

    # Extend and enlarge the the dag/layout with ancillas using the full coupling map
    pass_manager.append(ExtendLayout(coupling_map))
    pass_manager.append(EnlargeWithAncilla())

    # Swap mapper
    pass_manager.append(LegacySwap(coupling_map, trials=20, seed=seed_mapper))

    # Expand swaps
    pass_manager.append(Decompose(SwapGate))

    # Change CX directions
    pass_manager.append(CXDirection(coupling_map))

    # Unroll to the basis
    pass_manager.append(Unroller(["u1", "u2", "u3", "id", "cx"]))

    # Simplify single qubit gates and CXs
    if not skip_numeric_passes:
        simplification_passes = [Optimize1qGates(), CXCancellation()]
    else:
        simplification_passes = [CXCancellation()]

    pass_manager.append(
        simplification_passes + [Depth(), FixedPoint("depth")],
        do_while=lambda property_set: not property_set["depth_fixed_point"],
    )

    return pass_manager