Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ket convention statevector drawer ignores max_size #7516

Closed
frankharkins opened this issue Jan 11, 2022 · 7 comments · Fixed by #8197
Closed

Ket convention statevector drawer ignores max_size #7516

frankharkins opened this issue Jan 11, 2022 · 7 comments · Fixed by #8197
Assignees
Labels
bug Something isn't working

Comments

@frankharkins
Copy link
Member

Environment

  • Qiskit Terra version: 0.34.0
  • Python version: 3.9.8
  • Operating system: OSX

What is happening?

Currently, Statevector.draw('latex') ignores the max_size parameter.

How can we reproduce the issue?

from qiskit.quantum_info import Statevector
from qiskit.visualization.state_visualization import state_drawer

sv = Statevector.from_label('++++')
state_drawer(sv, 'latex', max_size=3)

Screenshot 2022-01-11 at 12 41 42

We get 12 terms, but I expect to get 3.

What should happen?

The drawer should change its behaviour according to the max_size parameter.

Any suggestions?

I think adding **args to this line might do it.
https://github.com/Qiskit/qiskit-terra/blob/5ea6e9557655b144228c29d7099375f5d2c91120/qiskit/visualization/state_visualization.py#L1183

@frankharkins
Copy link
Member Author

Happy to look at this properly, can you assign me please?

@IFWork
Copy link

IFWork commented Jun 6, 2022

Hi this issue has been causing me a real headache recently. Has there been any progress on it?

@jakelishman
Copy link
Member

I think the solution will be very slightly different to what Frank originally suggested, because the options to array_to_latex and _state_to_latex_ket are different, so we'll need to only pass the right options to each of those, but in principle that's the only change needed.

I'll just ping @frankharkins to check if you've got time to work on it? If not, I'll return it to the pool of good first issues for somebody else to take a look at.

@IFWork
Copy link

IFWork commented Jun 7, 2022

Oh and in case it isn't the same bug in the code, the same issue occurs with .draw(output="latex_source")

@frankharkins
Copy link
Member Author

Sorry I completely forgot about this, I'll have a look this week

@IFWork
Copy link

IFWork commented Jun 17, 2022

Has there been any luck at all?

@frankharkins
Copy link
Member Author

Yes, sorry- I've fixed and am just writing a test now.

frankharkins added a commit to frankharkins/qiskit-terra that referenced this issue Jun 17, 2022
@mergify mergify bot closed this as completed in #8197 Jun 21, 2022
mergify bot added a commit that referenced this issue Jun 21, 2022
* Fix #7516

* Remove unused import

* Improve splitting of string literals

Co-authored-by: Jake Lishman <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants