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

Data parameter from Operator class does not show properly in API reference #8506

Closed
Guillermo-Mijares-Vilarino opened this issue Aug 9, 2022 · 3 comments · Fixed by #8679
Labels
bug Something isn't working documentation Something is not clear or an error documentation good first issue Good for newcomers mod: quantum info Related to the Quantum Info module (States & Operators)

Comments

@Guillermo-Mijares-Vilarino
Copy link
Contributor

Guillermo-Mijares-Vilarino commented Aug 9, 2022

Environment

  • Qiskit Terra version: N/A
  • Python version: N/A
  • Operating system: N/A

What is happening?

The part of the Operator class API reference page from qiskit.quantum_info in which the parameters are listed does not show properly. In particular, where the data argument is supposed to be the page reads:

Parameters
or (data (QuantumCircuit) – Instruction or BaseOperator or matrix): data to initialize operator.

Instead of

Parameters
data (QuantumCircuit or Instruction or BaseOperator or matrix): data to initialize operator.

However I don't see any problem with the source code:

def __init__(self, data, input_dims=None, output_dims=None):
        """Initialize an operator object.

        Args:
            data (QuantumCircuit or
                  Instruction or
                  BaseOperator or
                  matrix): data to initialize operator.
            input_dims (tuple): the input subsystem dimensions.
                                [Default: None]
            output_dims (tuple): the output subsystem dimensions.
                                 [Default: None]

How can we reproduce the issue?

What should happen?

You should see the aforementioned error.

Any suggestions?

No response

@Guillermo-Mijares-Vilarino Guillermo-Mijares-Vilarino added the bug Something isn't working label Aug 9, 2022
@Guillermo-Mijares-Vilarino Guillermo-Mijares-Vilarino changed the title Operator class API reference page looks strange Data parameter from Operator class does not show properly in API reference Aug 9, 2022
@ikkoham ikkoham added good first issue Good for newcomers documentation Something is not clear or an error documentation mod: quantum info Related to the Quantum Info module (States & Operators) labels Aug 10, 2022
@ikkoham
Copy link
Contributor

ikkoham commented Aug 10, 2022

Thank you for finding the bug!

@javabster javabster moved this to Tagged but unassigned in Contributor Monitoring Aug 16, 2022
@dalin27
Copy link
Contributor

dalin27 commented Sep 4, 2022

As a follow up, could there be an issue with how the docstring is formatted? I am not very familiar with how the docstring is parsed using Napoleon (a Sphinx extension), but maybe the colon should be on the same line as data!? Maybe something like this:

Args:
      data (QuantumCircuit or Operation or BaseOperator or matrix): 
                          data to initialize operator.
      input_dims (tuple): the input subsystem dimensions.
                          [Default: None]
      output_dims (tuple): the output subsystem dimensions.
                           [Default: None]

Note also that due to some recent update in the operator.py file, the correct line that should appear in the API reference page is

data (QuantumCircuit or Operation or BaseOperator or matrix): data to initialize operator.

That is, Instruction has been replaced by Operation.

@jakelishman
Copy link
Member

@dalin27: yeah, I would expect that Sphinx's parser is probably choking because it's not finding the colon. Putting it on one line should help out.

The online documentation still says Instruction because the online documentation is for Terra 0.21.2, and the Operation interface is only on the main branch, and planned to be released in Terra 0.22. We're not planning to release a 0.21.3 patch (unless something super critical happens very soon), so any documentation fix would go out with 0.22.

@mergify mergify bot closed this as completed in #8679 Sep 10, 2022
Repository owner moved this from Tagged but unassigned to Done in Contributor Monitoring Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Something is not clear or an error documentation good first issue Good for newcomers mod: quantum info Related to the Quantum Info module (States & Operators)
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants