:py:mod:`qsearch.project` ========================= .. py:module:: qsearch.project .. autoapi-nested-parse:: This module provides a wrapper that makes it easier to interface with the rest of Qsearch. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: qsearch.project.Project_Status qsearch.project.Project Attributes ~~~~~~~~~~ .. autoapisummary:: qsearch.project.MPI .. py:data:: MPI .. py:class:: Project_Status Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: PROGRESS :value: 1 .. py:attribute:: COMPLETE :value: 2 .. py:attribute:: NOTBEGUN :value: 3 .. py:class:: Project(path, use_mpi=False) The project class wraps most of the functionality of Qsearch as intended to help manage working with Qsearch. .. py:property:: compilations The list of names corresponding to compilations on this Project. .. py:method:: _save() .. py:method:: _checkpoint_path(name) .. py:method:: add_compilation(name, U, options=None, handle_existing=None, **extraargs) Adds a unitary to be compiled. :param name: A name for this unitary. Must be unique in this Project. :param U: The unitary to be compiled, in the form of a numpy ndarray with dtype="complex128" :param handle_existing: A variable which defines how to behave if a compilation with the given name already exists. If it is set to "ignore", it will simply return without doing anything. If it is set to "overwrite", it will overwrite the previous entry. If it is set to the default of None, it will offer a warning asking the user to remove and re-add the compilation. :param options: The options passed to this function will be used only when this compilation is run. :param extraargs: The extraargs passed to this function will be used only when this compilation is run. .. py:method:: __setitem__(keyword, value) .. py:method:: configure_compiler_override(keyword, value) An unsafe method that allows the user to set global Project Options even if there is existing work. .. py:method:: __getitem__(keyword) .. py:method:: __delitem__(keyword) .. py:method:: configure(**dictionary) Adds multiple options to the global Project Options at once. .. py:method:: reset(name=None) Resets a Project, removing any work done but not the initial configurations. :param name: Optionally specify a particular compilation by name to reset .. py:method:: remove_compilation(name) Removes a compilation from a Project. :param name: The name of the compilation to remove .. py:method:: clear(name=None) Clears a Project, reverting it to a state similar to a newly created Project. :param name: Optionally specify a particular compilation by name to clear .. py:method:: __enter__() .. py:method:: __exit__(exc_typ, exc_val, exc_tb) .. py:method:: set_defaults(defaults=standard_defaults) Updates the Project Options with the standard defaults from defaults.py, or a provided dictionary. .. py:method:: set_smart_defaults(smart_defaults=standard_smart_defaults) Updates the Project Options with the standard smart_defaults from defaults.py, or a provided dictionary .. py:method:: run() Runs all of the compilations in the Project. .. py:method:: post_process(postprocessor, name=None, options=None, **xtraargs) Post-processes the specified compilation, or all compilations if name is None, using the specified postprocessor. :param postprocessor: The qsearch.post_processing.PostProcessor to run on the compilation or project :param name: Optionally specify a particular compilation by name to reset :param options: Options to pass to the qsearch.post_processing.PostProcessor passed in `postprocessor` :param extraargs: Extra arguments passed as options to the qsearch.post_processing.PostProcessor passed in `postprocessor` .. py:method:: complete() Returns a True if all compilations in the Project have finished and False otherwise. .. py:method:: finish() Called when done running compilations in order to end MPI tasks. .. py:method:: status(name=None, logger=None) Prints a status update on how much of a Project has finished running. :param name: Optionally specify which compilation to check the status of .. py:method:: _compilation_status(name) .. py:method:: _overall_status() .. py:method:: get_result(name) Get the result of a compilation. :param name: The name of the compilation to get the result dictionary from :returns: The result dictionary for a finished compilation. Usually this contains the entries "structure", a Gate, and "parameters", an array of real number parameters. :rtype: dict .. py:method:: get_target(name) Get the target unitary of a compilation. :param name: The name of the compilation to get the target from :returns: The target unitary of the compilation :rtype: np.ndarray .. py:method:: get_time(name) Get the runtime that it took to run a compilation. :param name: The name of the compilation to get the runtime of :returns: The number of seconds the compilation took :rtype: float .. py:method:: get_options(name=None) Get the qsearch.options.Options object from a compilation of project :param name: Optionally pass the name of the compilation to get the qsearch.options.Options object from :returns: the requested options object :rtype: qsearch.options.Options .. py:method:: assemble(name, options=None, **xtraargs) Assembles a compilation using the Assembler specified as assembler in the Options. :param name: The compilation to assemble :param options: Contains the qsearch.assemblers.Assembler to use in assembly :returns: The resulting assembled code :rtype: str