Skip to content

Commit

Permalink
Fix Result constructing a pandas dataframe to compute repetitions (#3801
Browse files Browse the repository at this point in the history
)

- This is really really expensive compared to looking up the value more directly like this
  • Loading branch information
Strilanc committed Feb 13, 2021
1 parent 0677d60 commit 3f965a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cirq/study/result.py
Expand Up @@ -150,7 +150,8 @@ def measurements(self) -> Dict[str, np.ndarray]:

@property
def repetitions(self) -> int:
return self.data.shape[0]
# Get the length quickly from one of the keyed results.
return len(next(iter(self.measurements.values())))

# Reason for 'type: ignore': https://github.com/python/mypy/issues/5273
def multi_measurement_histogram( # type: ignore
Expand Down

0 comments on commit 3f965a4

Please sign in to comment.