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

Add missing docstrings for EquivalenceLibrary #13291

Merged
merged 4 commits into from
Nov 6, 2024

Conversation

raynelfss
Copy link
Contributor

Summary

The following commits attempt to fix #13258 by adding all of the missing docstrings that were lost after #12585.

Details and comments

Add missing docstrings in the following methods:

  • Python (PyO3):
    • EquivalenceLibrary struct class.
    • EquivalenceLibrary::get_graph method.
    • EquivalenceLibrary::py_keys method.
    • EquivalenceLibrary::py_node_index method.
  • Rust:
    • EquivalenceLibrary::keys method.

@raynelfss raynelfss requested a review from a team as a code owner October 7, 2024 18:34
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@raynelfss raynelfss changed the title Initial: Add missing docstrings for EquivalenceLibrary Add missing docstrings for EquivalenceLibrary Oct 7, 2024
crates/accelerate/src/equivalence.rs Outdated Show resolved Hide resolved
crates/accelerate/src/equivalence.rs Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Oct 7, 2024

Pull Request Test Coverage Report for Build 11709092718

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 2 (0.0%) changed or added relevant lines in 1 file are covered.
  • 2385 unchanged lines in 129 files lost coverage.
  • Overall coverage decreased (-0.1%) to 88.774%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/accelerate/src/equivalence.rs 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py 1 96.3%
qiskit/circuit/library/iqp.py 1 96.15%
qiskit/transpiler/passes/calibration/pulse_gate.py 1 95.45%
qiskit/circuit/library/boolean_logic/quantum_or.py 1 98.08%
qiskit/pulse/instructions/reference.py 1 93.55%
qiskit/circuit/library/standard_gates/u.py 1 93.0%
qiskit/circuit/library/boolean_logic/quantum_and.py 1 97.96%
qiskit/synthesis/unitary/qsd.py 1 97.58%
qiskit/pulse/instructions/directives.py 1 97.14%
qiskit/circuit/library/boolean_logic/inner_product.py 1 96.0%
Totals Coverage Status
Change from base Build 11219438971: -0.1%
Covered Lines: 77108
Relevant Lines: 86859

💛 - Coveralls

@raynelfss raynelfss added this to the 1.3.0 milestone Oct 31, 2024
@raynelfss raynelfss added the documentation Something is not clear or an error documentation label Oct 31, 2024
///
/// # Arguments:
/// * `key`: The `Key` to look for.
/// ## Arguments:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to go with H2 here?

Copy link
Contributor Author

@raynelfss raynelfss Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing more than just me thinking H1 looks a bit too big here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, understandable. Regardless, it looks like the Rust standard library uses H1 for a first level section, but it also looks like documenting arguments separately like we do in Python is actually not hip in Rust.

I would recommend that we just remove the Arguments and Returns sections on all of these methods altogether. To describe arguments that aren't self-explanatory, add a second paragraph after the summary sentence to describe the usage.

Here's what the Rust standard library uses as their convention: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text

Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python docs look good. I left one comment recommending we use lowercase generic terms in cases where we don't want to make a code reference to a type. In general, prefer circuit or :class:`.QuantumCircuit` over QuantumCircuit. This is a fairly standard practice, e.g. Rust gives this guidance in its standard library style guide. The rationale that comes to mind is that if we know the exact type in question, we might as well use a code reference.

As for the Rust docs, I'd recommend we drop all of the Args and Returns sections, and stick with just a summary sentence, followed by an optional paragraph that describes any usage details. It's just not standard practice in Rust to list out arguments like we see in Python docs. Instead, the Rust community favors a cohesive usage description of the function as a whole when arguments aren't obvious, along with an Examples section, ideally for every method to provide usage examples. It's probably alright to skip the Examples section for most of the methods you've got in this PR, since the usage is self-explanatory and this is not yet a public interface.

@raynelfss raynelfss added the Changelog: None Do not include in changelog label Nov 5, 2024
- Add docs links based on @kevinhartman's comments.
- Add sphinx friendly labels in docstrings.
crates/accelerate/src/equivalence.rs Outdated Show resolved Hide resolved
crates/accelerate/src/equivalence.rs Outdated Show resolved Hide resolved
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this.

@mtreinish mtreinish added this pull request to the merge queue Nov 6, 2024
Merged via the queue into Qiskit:main with commit 0538efb Nov 6, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog documentation Something is not clear or an error documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in EquivalenceLibrary documentation from oxidation
5 participants