-
Notifications
You must be signed in to change notification settings - Fork 48
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
Tidy up pytket.circuit
API docs
#1178
Conversation
@@ -14,104 +14,104 @@ pytket.circuit | |||
|
|||
.. automodule:: pytket._tket.circuit | |||
:members: fresh_symbol | |||
.. autoclass:: pytket._tket.circuit.Op |
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 think all of this _tket stuff is replaced in the docs build anyway. I don't think theres any good reason for it to be in the rst source
# The paper size ('letterpaper' or 'a4paper'). | ||
# | ||
# 'papersize': 'letterpaper', | ||
# The font size ('10pt', '11pt' or '12pt'). |
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.
Don't think these config settings do anything
@@ -99,6 +100,7 @@ | |||
# | |||
|
|||
html_theme_options = { | |||
"show_toc_level": 2, |
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.
This config setting populates the right sidebar for all of the docs.
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.
Having made a start at cross-checking these circuit docs with the existing ones, I think we need a script to do it for us.
I found the following missing Circuit
methods, before I stopped looking: CU1
, CU3
, Reset
, TK2
, ZZMax
, add_c_not
.
Could you perhaps write a script that iterates over all Circuit
methods (use Circuit.__dict__.keys()
) and lists any that do not occur in circuit_class.rst
?
# print all members of Circuit that don't start with underscore that don't occur in the docs
import inspect
import re
from pytket._tket.circuit import Circuit
# paste contents of https://github.com/CQCL/tket/blob/7b0df5cf68503944cd34e593fb094ba5aa4357f4/pytket/docs/circuit_class.rst
rst = ...
in_methods = {p[0] for p in inspect.getmembers(Circuit)}
pattern = re.compile(r"(?:\bautomethod\b|\bautoproperty\b):: (\w+)\n")
in_docs = set(pattern.findall(rst))
missing = in_methods - in_docs
print([s for s in missing if not s.startswith("_")]) Output: ['CU1', 'discarded_qubits', 'bit_readout', 'Reset', 'valid_connectivity', 'CU3', 'add_multiplexed_tensored_u2', 'symbol_substitution', 'add_conditional_barrier', 'add_c_not', 'qubit_to_bit_map', 'ZZMax', 'created_qubits', 'depth_by_type', 'is_symbolic', 'add_phasepolybox', 'name', 'substitute_named', 'TK2'] |
Thanks @ss2165 you beat me to it |
I've added the missing methods found by the script. Not sure if its worth using the script as part of the CI checks or whether we should just do a one-off check. The script seems to show |
That's very strange. Can we check in the script to the repo, as it will be useful in future even if we don't run it on the CI? |
Done, added the script. |
pytket/docs/circuit_class.rst
Outdated
.. automethod:: to_latex_file | ||
|
||
|
||
Convenience methods for appending circuit operations |
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 think this should be a heading?
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.
Made it a heading
pytket/docs/circuit_class.rst
Outdated
|
||
.. automethod:: depth_2q | ||
|
||
.. automethod:: depth_by_type |
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.
There's a space at the end of this line: that's why the script wasn't detecting it.
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.
thanks, fixed it
|
||
from pytket._tket.circuit import Circuit | ||
|
||
# paste contents of https://github.com/CQCL/tket/blob/7b0df5cf68503944cd34e593fb094ba5aa4357f4/pytket/docs/circuit_class.rst |
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 don't think we want this comment?
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.
removed
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.
Can we put a couple of lines of commentary at the top of this file to explain what it does and why?
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.
Done.
Description
First pass of cleaning up the
pytket.circuit
documentation, still plenty more to do... automethod::
to add eachCircuit
method individually. This means we can move the methods we want people to use to the top of the docs (i.e. Circuit.add_gate) and move others to the bottom (i.eCircuit.add_add_pauliexpcommutingsetbox
andCircuit.CX
)If anyone knows how to get control of the ordering without using
automethod
hundreds of times then PLEASE let me know.added some notes saying that
add_gate
is sufficent to add append any box to a circuit rather than usingCircuit.add_x_box
. Also saying that using the convenices methods likeCircuit.CX(0, 1)
are equiavlent to usingCircuit.add_gate(OpType.CX, [0, 1])
.Don't clutter the
pytket.circuit
page by expanding thelogic_exp
classesbefore
after
"show_toc_level": 2
inhtml_theme_options
.before
after
Checklist