Browse code

Rename local variable 'n' to 'n_qubits' in 'from_classical'

This makes the function a bit clearer.

Joseph Weston authored on 15/11/2019 17:52:56
Showing 1 changed files
... ...
@@ -30,12 +30,12 @@ def from_classical(bitstring):
30 30
     """
31 31
 
32 32
     bitstring = "".join(map(str, bitstring))
33
-    n = len(bitstring)
33
+    n_qubits = len(bitstring)
34 34
     try:
35 35
         index = int(bitstring, base=2)
36 36
     except ValueError:
37 37
         raise ValueError("Input is not a classical bitstring") from None
38 38
 
39
-    state = np.zeros(2 ** n, dtype=complex)
39
+    state = np.zeros(1 << n_qubits, dtype=complex)
40 40
     state[index] = 1
41 41
     return state