Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

Work-in-progess: Add an option to highlight a subset of qubits in cirq.Heatmap

Open kris524 opened this issue 2 years ago • 4 comments

These are the first few changes. Next, I will focus on adding some new tests. This is still a WIP

kris524 avatar Jun 22 '22 20:06 kris524

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Update: I am very close to completing the bit with edge_colors logic. The only issue I am faced with is, the state of the list I look in is:

[(cirq.GridQubit(0, 5),), (cirq.GridQubit(8, 1),), (cirq.GridQubit(7, 0),), (cirq.GridQubit(13, 5),), (cirq.GridQubit(1, 6),), (cirq.GridQubit(3, 2),), (cirq.GridQubit(2, 8),)]

The reason for this is because self._value_map is defined to have QubitTuple keys and for my tests/edits I have focused on grid_qubit.GridQubit. I am tempted to suggest a refactor of this self._value_map declaration at the start of the Heatmap class but I might be wrong and there could be a better way

This prevents the detection of a clear qubit in the form (if we were looking for it for example) cirq.GridQubit(0, 5) Hence this is a very annoying situation

kris524 avatar Jun 25 '22 21:06 kris524

I believe I only have tests left (for Heatmaps, next is TwoQubitInteractionHeatmap). There is a heatmaps.py in the examples folder that I can run but I don't see any plots. Also, a Jupyter notebook only gives me ValueError: Received invalid argument(s): selected_qubits while all tests in heatmap_test.py pass (except test_annotation_map).

kris524 avatar Jun 25 '22 23:06 kris524

Apologies for the delay. I was working on this from time to time I was having trouble with my setup. I think I have implemented the base logic and have a test showing that when I pass a selected_qubits argument in the plot(), it will update the collection_options accordingly. However, I am having trouble displaying the plot inside a pytest. I went around this issue by saving the figure using plt.savefig("mygraph.png") which I will remove later

Next, I plan to fix all the failing tests and add more tests for this new feature.

kris524 avatar Aug 20 '22 14:08 kris524