Repository: PennyLaneAI/pennylane

Issue:
`qml.fourier.coefficients` won't  work with more than one expectation value
#### Issue description

When I try to calculate the Fourier coefficients with the new module `qml.fourier` if the circuit has more than one measurement an error appears.

#### Code:
```python
import pennylane as qml
from pennylane import numpy as np
from pennylane.fourier import coefficients

dev = qml.device('default.qubit', wires=2)

@qml.qnode(dev)
def simple_circuit(x):
    qml.RX(x[0], wires=0)
    qml.RY(x[0], wires=1)
    qml.CNOT(wires=[1, 0])
    return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))


coeffs = coefficients(simple_circuit, 1, 2)
print(np.round(coeffs, decimals=4))
```
#### Output:
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: only size-1 arrays can be converted to Python scalars

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
<ipython-input-111-8c2ae78fdea3> in <module>
     13 
     14 
---> 15 coeffs = coefficients(simple_circuit, 1, 2)
     16 print(np.round(coeffs, decimals=4))

~/.local/lib/python3.8/site-packages/pennylane/fourier/coefficients.py in coefficients(f, n_inputs, degree, lowpass_filter, filter_threshold)
    154     """
    155     if not lowpass_filter:
--> 156         return _coefficients_no_filter(f, n_inputs, degree)
    157 
    158     if filter_threshold is None:

~/.local/lib/python3.8/site-packages/pennylane/fourier/coefficients.py in _coefficients_no_filter(f, n_inputs, degree)
    228 
    229         # fill discretized function array with value of f at inpts
--> 230         f_discrete[tuple(nvec)] = f(sample_points)
    231 
    232     coeffs = np.fft.fftn(f_discrete) / f_discrete.size

ValueError: setting an array element with a sequence.
```


Discussion:
Hi @PCesteban, thank you for posting! We'll have a look at it.

Resolving patch:
diff --git a/pennylane/fourier/coefficients.py b/pennylane/fourier/coefficients.py
--- a/pennylane/fourier/coefficients.py
+++ b/pennylane/fourier/coefficients.py
@@ -55,7 +55,8 @@ def coefficients(f, n_inputs, degree, lowpass_filter=False, filter_threshold=Non
     :math:`c_{n_1,\ldots,n_N}` are Fourier coefficients.
 
     Args:
-        f (callable): Function that takes a 1D tensor of ``n_inputs`` scalar inputs.
+        f (callable): Function that takes a 1D tensor of ``n_inputs`` scalar inputs. The function can be a QNode, but
+            has to return a real scalar value (such as an expectation).
         n_inputs (int): number of function inputs
         degree (int): max frequency of Fourier coeffs to be computed. For degree :math:`d`,
             the coefficients from frequencies :math:`-d, -d+1,...0,..., d-1, d` will be computed.
@@ -87,6 +88,10 @@ def circuit(weights, inpt):
 
             return qml.expval(qml.PauliZ(wires='a'))
 
+    .. note::
+
+        The QNode has to return a scalar value (such as a single expectation).
+
     Unless otherwise specified, the coefficients will be computed for all input
     values. To compute coefficients with respect to only a subset of the input
     values, it is necessary to use a wrapper function (e.g.,


Test patch: