Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions qiskit/transpiler/passmanager_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,24 @@ def from_backend(cls, backend, **pass_manager_options):
res.target = backend.target

return res

def __str__(self):
return (
"Pass Manager Config:\n"
Comment on lines +138 to +139

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't feel very strongly about this at all, but is it worth formatting it as

f"""
PassManagerConfig(
    initial_layout={self.initial_layout},
    basis_gates={self.basis_gates},
...
)
"""

so it can easily be copy-paste evaled back into an interpreter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure if it's useful to do that in this case because this is not actually going to be a repr string in this case. You won't be able to eval the output because several of the fields are more complex objects that have human readable outputs (InstructionScheduleMap, InstructionDurations, CouplingMap, Target, etc)

I personally was just looking for something that I could use for quick print debugging in #7789 that gave me output I could read to show what was getting passed to the PassManagerConfig

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm fine with this - what I was suggesting is more like for repr anyway.

f"\tinitial_layout: {self.initial_layout}\n"
f"\tbasis_gates: {self.basis_gates}\n"
f"\tinst_map: {self.inst_map}\n"
f"\tcoupling_map: {self.coupling_map}\n"
f"\tlayout_method: {self.layout_method}\n"
f"\trouting_method: {self.routing_method}\n"
f"\ttranslation_method: {self.translation_method}\n"
f"\tscheduling_method: {self.scheduling_method}\n"
f"\tinstruction_durations: {self.instruction_durations}\n"
f"\tbackend_properties: {self.backend_properties}\n"
f"\tapproximation_degree: {self.approximation_degree}\n"
f"\tseed_transpiler: {self.seed_transpiler}\n"
f"\ttiming_constraints: {self.timing_constraints}\n"
f"\tunitary_synthesis_method: {self.unitary_synthesis_method}\n"
f"\tunitary_synthesis_plugin_config: {self.unitary_synthesis_plugin_config}\n"
f"\ttarget: {self.target}\n"
)