See also

This notebook can be downloaded here

UML class diagram generator#

  • This notebook generates UML diagrams of class hierarchies

  • Dependencies: pylint, ipykernel (install these two in a python env), graphviz

from IPython.display import Image, display
from quantify_scheduler.helpers.inspect import make_uml_diagram

General notes#

  • Yellow labels indicate addition as a submodule

  • Different colors indicate different packages

  • Generated figures are saved in png format

  • Options must be given in list[str] format

  • For more information, visit the Wikipedia page on relationships in class diagrams

Plotting all classes in a module#

  • Be aware that this option will only plot classes that are contained within module_to_plot, and not related classes defined outside the module.

  • Extra options:

    • Show ancestors (aka parent classes): -A

    • Ignore specific submodules: --ignore <file[,file...]> (e.g. ["--ignore", "circuit_to_device.py,corrections.py,zhinst"])

from quantify_scheduler.backends import qblox

module_to_plot = qblox
options = ["-A"]

diagram_name = make_uml_diagram(module_to_plot, options)
if diagram_name:
    display(Image(diagram_name))
../_images/eb8c280a2ffddb9b184fdbdc0f0528b939cb87c63929b6bcb3ec4ac6902078bc.png

Plotting ancestors and submodules of a class#

  • Remove --only-classnames option to show all class attributes

from quantify_scheduler.device_under_test.transmon_element import BasicTransmonElement

class_to_plot = BasicTransmonElement
options = ["--only-classnames"]

diagram_name = make_uml_diagram(class_to_plot, options)
if diagram_name:
    display(Image(diagram_name))
../_images/593154af00bae6fb3c515e4073e8a11813da5978b76cb97b0ae60713dcace2e1.png