def build_wigner_circuits(q_program, name, phis, thetas, qubits,
                          qreg, creg, silent=False):
    """Create the circuits to rotate to points in phase space
    Args:
        q_program (QuantumProgram): A quantum program to store the circuits.
        name (string): The name of the base circuit to be appended.
        phis (np.matrix[[complex]]):
        thetas (np.matrix[[complex]]):
        qubits (list[int]): a list of the qubit indexes of qreg to be measured.
        qreg (QuantumRegister): the quantum register containing qubits to be
                                measured.
        creg (ClassicalRegister): the classical register containing bits to
                                    store measurement outcomes.
        silent (bool, optional): hide verbose output.

    Returns: A list of names of the added wigner function circuits.
    """
    orig = q_program.get_circuit(name)
    labels = []
    points = len(phis[0])

    for point in range(points):
        label = '_wigner_phase_point'
        label += str(point)
        circuit = q_program.create_circuit(label, [qreg], [creg])

        for qubit in range(len(qubits)):
            circuit.u3(thetas[qubit][point], 0,
                       phis[qubit][point], qreg[qubits[qubit]])
            circuit.measure(qreg[qubits[qubit]], creg[qubits[qubit]])

        q_program.add_circuit(name + label, orig + circuit)
        labels.append(name+label)

    if not silent:
        print('>> created Wigner function circuits for "%s"' % name)
    return labels