diff --git a/src/tequila/wavefunction/qubit_wavefunction.py b/src/tequila/wavefunction/qubit_wavefunction.py index ce40f3a4..82d6e67d 100644 --- a/src/tequila/wavefunction/qubit_wavefunction.py +++ b/src/tequila/wavefunction/qubit_wavefunction.py @@ -365,7 +365,7 @@ def normalize(self, inplace: bool = False) -> QubitWaveFunction: # because the __mul__ implementation of the number tries to perform some sort of array # operation. def length(self): - return sum(1 for _ in self.raw_items()) + return sum(1 for (k, v) in self.raw_items() if abs(v) > 1e-6) def __repr__(self): result = str()