quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.24k stars 1.01k forks source link

Can't print the `ResultDict` of an array with 2 values #6447

Closed vtomole closed 7 months ago

vtomole commented 7 months ago

Description of the issue cirq.ResultDict(records={'c': np.array([[[True], [True]]])}) can be created but it can't be printed .

How to reproduce the issue

import cirq
import numpy as np
result = cirq.ResultDict(records={'c': np.array([[[True], [True]]])})
print(result)

Will throw ValueError: Cannot extract 2D measurements for repeated keys

Cirq version 1.4.0.dev20240126200039

NoureldinYosri commented 7 months ago

cirq-cync: needs to invistigate whether the input is valid (and add input validation) and if it's find out the bug in printing.


update: the bug is in the __str__ and __repr__ which use measurements instead of records.