Closed MubasharK closed 1 year ago
@MubasharK
array_to_latex
rounds this to 5 by default, but you can display 14 decimal places of precision using the argument precision=14
max_size
to some value that's greater than, or equal to, your array size. If your array is a numpy array, you can set it to that array's .shape
.
from qiskit.visualization import array_to_latex
import numpy as np
arr = np.random.random((50,50)) # max large numpy array
array_to_latex(arr, precision=14, max_size=arr.shape)
You can read about this and other features in the docs.
Thank you Frank Harkins! Please see the below file. The output of block 4 and 5 is my concern. With including precision=14 in the command array_to_latex one issue has been resolved. But, not all entries of the output array are explicitly listed. The state (array) is initialized using from qiskit.quantum_info import Statevector state = Statevector.from_int(0, 2**7) state = state.evolve(qc)
state.draw('latex') Multi qubit controlled rotations.pdf
Replace:
array_to_latex(state) --> array_to_latex(state, max_size=2**7, precision=14)
Looks like the ket convention drawer is ignoring max size, I've added a bug report for this (https://github.com/Qiskit/qiskit-terra/issues/7516). Once fixed, I think you should be able to do state.draw('latex', max_size=2**7)
to get what you want.
Hello Harkins,
Hope you are well.
The issue (#7516 https://github.com/Qiskit/qiskit-terra/issues/7516) is still open and I am unable to retrieve all the entries using the command state.draw('latex', max_size=2**7). Is there any progress about this?
Best, Mubashar
On Tue, 11 Jan 2022 at 17:46, Frank Harkins @.***> wrote:
Replace:
array_to_latex(state) --> array_to_latex(state, max_size=2**7, precision=14)
Looks like the ket convention drawer is ignoring max size, I've added a bug report for this (#7516 https://github.com/Qiskit/qiskit-terra/issues/7516). Once fixed, I think you should be able to do state.draw('latex', max_size=2**7) to get what you want.
— Reply to this email directly, view it on GitHub https://github.com/Qiskit/qiskit-terra/issues/7495#issuecomment-1009930819, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXGEYE5D5PTGFTC77RH3ZNTUVQRCNANCNFSM5LOFNBLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
Closing as it looks like this was resolved as part of #7516 . Please feel free to re-open if you're still seeing this issue.
What should we add?
I want to ask two questions as I could not find answer to them on this forum and elsewhere. First, what is a precision of an array representing a quantum state which has been evolved via quantum circuit in Qiskit. Second, the command array to latex does not output all entries of the array instead it displays few entries with ellipses in between them. How can we get complete array with precision up to 14 decimal places (say)? According to my observations, the precision seems to be 5 decimal places. If it is true, then how one can enhance it? Also, I request you to update the output of array to latex in Qiskit so that all elements of the output tuple are explicitly listed.