node-red-quantum / node-red-contrib-quantum

Quantum computing functionality for Node-RED
https://node-red-quantum.github.io/
Apache License 2.0
18 stars 2 forks source link

Chon/bloch sphere #67

Closed XxWirusonxX closed 3 years ago

XxWirusonxX commented 3 years ago

Purpose

Added in Bloch Sphere Diagram Node to the Project. Currently Trying to fix the problem where when the Quantum Circuit included Measures, it pops out error. [maybe duplicate the qc into qc for measures and qc for diagrams ?]

Changes

Added Bloch Sphere to the Quantum Folder.

New Requirements

Due to the Problem mention here, In order to get Bloch Sphere Diagram Node works, you are require to change the bloch.py in venv/lib/python3.9/site-packages/qiskit/visualization/bloch.py at line 68 from:

x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)

into

x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M)

or use the following version of Matplotlib: Matplotlib = 3.3.4

else the Bloch Sphere Diagram will not work.

Theo-Reignier commented 3 years ago

@XxWirusonxX Is this PR ready for review?

XxWirusonxX commented 3 years ago

@Theo-Reignier I have a few more to test, more on the problem with measures.

Theo-Reignier commented 3 years ago

Hey Chon,

I tried to test the block sphere node but a new error message was raised (see below).

Screenshot 2021-08-07 at 00 42 04

In the meantime, I have committed some minor changes such as the node's appearance and formatting.

XxWirusonxX commented 3 years ago

Hey Chon,

I tried to test the block sphere node but a new error message was raised (see below).

Screenshot 2021-08-07 at 00 42 04

In the meantime, I have committed some minor changes such as the node's appearance and formatting.

Thanks for testing it out @Theo-Reignier :), this error caused by using Official Qiskit, Yes !! Official Qiskit is still using a deprecated function from Mathplotlib therefore, it will pop up such error! Please have a look at the New Requirements from this PR and see if you still want to modify the bloch.py from Official Qiskit, or if theres any possible way to get around this problem, feel free to make changes :D

Theo-Reignier commented 3 years ago

@XxWirusonxX I am not sure I fully understand the issue. Using x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M) would solve the problem ?

XxWirusonxX commented 3 years ago

@XxWirusonxX I am not sure I fully understand the issue. Using x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M) would solve the problem ?

Yes it will fix the problem.

Theo-Reignier commented 3 years ago

@XxWirusonxX I am not sure I fully understand the issue. Using x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M) would solve the problem ?

Yes it will fix the problem.

In that case we should implement it before merging the PR, can you take care of this @XxWirusonxX ?

XxWirusonxX commented 3 years ago

@XxWirusonxX I am not sure I fully understand the issue. Using x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M) would solve the problem ?

Yes it will fix the problem.

In that case we should implement it before merging the PR, can you take care of this @XxWirusonxX ?

The problem is, Qiskit will not be there until we run the “npm run setup”

XxWirusonxX commented 3 years ago

Problem solved by using Matplotlib version 3.3.4

louislefevre commented 3 years ago

I pushed a commit f4c1e2c8e161d6b7c239fce3911abb2e62f7f6a5 to specify in the virtual environment setup script which version of matplotlib should be used.

louislefevre commented 3 years ago

@XxWirusonxX Are all the bugs dealt with and is this ready to be merged?

XxWirusonxX commented 3 years ago

@XxWirusonxX Are all the bugs dealt with and is this ready to be merged?

I believed the bloch sphere diagram node is fine, except the Error code occur whenever the measure node exist in the flow, it is good to go. As Theo mentioned before, its better to keep the Error code in so that people knows that measurements should not be part in the bloch sphere diagram.

Overall, the way to make the BSD Node without problem is abit different from other output diagram.

Theo-Reignier commented 3 years ago

@XxWirusonxX Are all the bugs dealt with and is this ready to be merged?

I believed the bloch sphere diagram node is fine, except the Error code occur whenever the measure node exist in the flow, it is good to go. As Theo mentioned before, its better to keep the Error code in so that people knows that measurements should not be part in the bloch sphere diagram.

Overall, the way to make the BSD Node without problem is abit different from other output diagram.

Well, even though it is not very useful, you can also use the 'simulator' node and 'IBM-quantum-system' nodes without 'measurement' nodes.

Therefore, I believe it is not that much different, we'll just have to insist on the fact that no 'measurement' nodes should be used with the 'bloch sphere' node.

Ideally, we could handle the error ourselves and display a more user-friendly error message. For example, the BSD node could search the python shell script for qc.m( . If the codes finds qc.m( then the node throws an error

Theo-Reignier commented 3 years ago

I am approving because it looks good to me. However, since I have a recent matplotlib version on my python shell, I still receive the same error.

I would appreciate if one of you guys with the correct matplotlib version could test it !