QuTech-Delft / OpenQL

OpenQL: A Portable Quantum Programming Framework for Quantum Accelerators. https://dl.acm.org/doi/10.1145/3474222
https://openql.readthedocs.io
Other
99 stars 44 forks source link

Add initialize() to Python API #380

Closed jvanstraten closed 3 years ago

jvanstraten commented 3 years ago

This adds ql.initialize() to the Python interface. It's purpose is to ensure that OpenQL is put in a well-defined, default state. Currently that only amounts to resetting options to their default values. If an option is set or a platform is constructed before initialize() is called, initialize() is called automatically and a warning is printed; this is just there for backward compatibility, and to teach people to call it themselves. The latter is necessary in the context of a shared python interpreter, such as a ipython/jupyter running on a shared server or during test suites, to prevent side-effects from the previous runs of OpenQL from affecting the latest run.

This replaces the current behavior of resetting options implicitly at the end of compile().