-
Notifications
You must be signed in to change notification settings - Fork 81
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
Fix API generation regression #899
Fix API generation regression #899
Conversation
Thanks for contributing to Qiskit documentation! Before your PR can be merged, it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. Thanks! 🙌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
This would also be great to test, but totally fine to do in a follow up.
### DEFAULT\_CONFIGURATION = \{'backend\_name' | ||
|
||
`= {'backend_name':` | ||
### DEFAULT\_CONFIGURATION | ||
|
||
`= {'backend_name': 'qasm_simulator', 'backend_version': '2.1.0', 'basis_gates': ['u1', 'u2', 'u3', 'rz', 'sx', 'x', 'cx', 'id', 'unitary'], 'conditional': True, 'coupling_map': None, 'description': 'A python simulator for qasm experiments', 'gates': [{'name': 'u1', 'parameters': ['lambda'], 'qasm_def': 'gate u1(lambda) q { U(0,0,lambda) q; }'}, {'name': 'u2', 'parameters': ['phi', 'lambda'], 'qasm_def': 'gate u2(phi,lambda) q { U(pi/2,phi,lambda) q; }'}, {'name': 'u3', 'parameters': ['theta', 'phi', 'lambda'], 'qasm_def': 'gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }'}, {'name': 'rz', 'parameters': ['phi'], 'qasm_def': 'gate rz(phi) q { U(0,0,phi) q; }'}, {'name': 'sx', 'parameters': [], 'qasm_def': 'gate sx(phi) q { U(pi/2,7*pi/2,pi/2) q; }'}, {'name': 'x', 'parameters': [], 'qasm_def': 'gate x q { U(pi,7*pi/2,pi/2) q; }'}, {'name': 'cx', 'parameters': [], 'qasm_def': 'gate cx c,t { CX c,t; }'}, {'name': 'id', 'parameters': [], 'qasm_def': 'gate id a { U(0,0,0) a; }'}, {'name': 'unitary', 'parameters': ['matrix'], 'qasm_def': 'unitary(matrix) q1, q2,...'}], 'local': True, 'max_shots': 65536, 'memory': True, 'n_qubits': 24, 'open_pulse': False, 'simulator': True, 'url': 'https://github.com/Qiskit/qiskit-terra'}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if we should go back to the qiskit.org style of the default value being on the same line as the attribute. But this example makes it clear that that won't work. The default value and type hint might be way too long.
@@ -216,9 +216,7 @@ Expanded Pass manager stages including `pre_` and `post_` phases. | |||
|
|||
<span id="qiskit.transpiler.StagedPassManager.invalid_stage_regex" /> | |||
|
|||
### invalid\_stage\_regex = re.compile('\\\s|\\\\+|\\\\-|\\\\\*|\\\\/|\\\\\\\\|\\\\%|\\\\\<|\\\\>|\\\\@|\\\\!|\\\\\~|\\\\^|\\\\&|\\\\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!!!!
Closes Qiskit#224 This PR fixes an issue with the API generation script that causes regressions in attributes. For each attribute, we show on the documentation website, its type (if exists) and its default value (if exists). An example of an attribute could be `instance: str | None = None` which has the type `str | None` and the default value `None`. This is its representation on the website: ![Captura desde 2024-02-27 19-12-42](https://github.com/Qiskit/documentation/assets/47946624/e2cce336-9d0a-4da7-bd80-3f7d7cf1f6c4) To find the attribute and the default value, the script searches for the index of the colon (type separator) and the index of the equal sign (default value separator). The problem is that those two values are optional, and we could have, for example, a default value involving a string containing a colon symbol that would be detected as the type separator when it's not. To fix this, we could only search for the type separator before the default value. We don't have any problem with the equal sign because it cannot be a type of attribute. The PR has regenerated all versions of qiskit, runtime, and provider.
Closes #224
This PR fixes an issue with the API generation script that causes regressions in attributes. For each attribute, we show on the documentation website, its type (if exists) and its default value (if exists).
An example of an attribute could be
instance: str | None = None
which has the typestr | None
and the default valueNone
. This is its representation on the website:To find the attribute and the default value, the script searches for the index of the colon (type separator) and the index of the equal sign (default value separator). The problem is that those two values are optional, and we could have, for example, a default value involving a string containing a colon symbol that would be detected as the type separator when it's not.
To fix this, we could only search for the type separator before the default value. We don't have any problem with the equal sign because it cannot be a type of attribute.
The PR has regenerated all versions of qiskit, runtime, and provider.