qsearch.project
¶
This module provides a wrapper that makes it easier to interface with the rest of Qsearch.
Module Contents¶
Classes¶
Generic enumeration. |
|
The project class wraps most of the functionality of Qsearch as intended to help manage working with Qsearch. |
Attributes¶
- qsearch.project.MPI¶
- class qsearch.project.Project_Status¶
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- PROGRESS = 1¶
- COMPLETE = 2¶
- NOTBEGUN = 3¶
- class qsearch.project.Project(path, use_mpi=False)¶
The project class wraps most of the functionality of Qsearch as intended to help manage working with Qsearch.
- property compilations¶
The list of names corresponding to compilations on this Project.
- _save()¶
- _checkpoint_path(name)¶
- add_compilation(name, U, options=None, handle_existing=None, **extraargs)¶
Adds a unitary to be compiled.
- Parameters:
name – A name for this unitary. Must be unique in this Project.
U – The unitary to be compiled, in the form of a numpy ndarray with dtype=”complex128”
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.
options – The options passed to this function will be used only when this compilation is run.
extraargs – The extraargs passed to this function will be used only when this compilation is run.
- __setitem__(keyword, value)¶
- configure_compiler_override(keyword, value)¶
An unsafe method that allows the user to set global Project Options even if there is existing work.
- __getitem__(keyword)¶
- __delitem__(keyword)¶
- configure(**dictionary)¶
Adds multiple options to the global Project Options at once.
- reset(name=None)¶
Resets a Project, removing any work done but not the initial configurations.
- Parameters:
name – Optionally specify a particular compilation by name to reset
- remove_compilation(name)¶
Removes a compilation from a Project.
- Parameters:
name – The name of the compilation to remove
- clear(name=None)¶
Clears a Project, reverting it to a state similar to a newly created Project.
- Parameters:
name – Optionally specify a particular compilation by name to clear
- __enter__()¶
- __exit__(exc_typ, exc_val, exc_tb)¶
- set_defaults(defaults=standard_defaults)¶
Updates the Project Options with the standard defaults from defaults.py, or a provided dictionary.
- set_smart_defaults(smart_defaults=standard_smart_defaults)¶
Updates the Project Options with the standard smart_defaults from defaults.py, or a provided dictionary
- run()¶
Runs all of the compilations in the Project.
- post_process(postprocessor, name=None, options=None, **xtraargs)¶
Post-processes the specified compilation, or all compilations if name is None, using the specified postprocessor.
- Parameters:
postprocessor – The qsearch.post_processing.PostProcessor to run on the compilation or project
name – Optionally specify a particular compilation by name to reset
options – Options to pass to the qsearch.post_processing.PostProcessor passed in postprocessor
extraargs – Extra arguments passed as options to the qsearch.post_processing.PostProcessor passed in postprocessor
- complete()¶
Returns a True if all compilations in the Project have finished and False otherwise.
- finish()¶
Called when done running compilations in order to end MPI tasks.
- status(name=None, logger=None)¶
Prints a status update on how much of a Project has finished running.
- Parameters:
name – Optionally specify which compilation to check the status of
- _compilation_status(name)¶
- _overall_status()¶
- get_result(name)¶
Get the result of a compilation.
- Parameters:
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.
- Return type:
dict
- get_target(name)¶
Get the target unitary of a compilation.
- Parameters:
name – The name of the compilation to get the target from
- Returns:
The target unitary of the compilation
- Return type:
np.ndarray
- get_time(name)¶
Get the runtime that it took to run a compilation.
- Parameters:
name – The name of the compilation to get the runtime of
- Returns:
The number of seconds the compilation took
- Return type:
float
- get_options(name=None)¶
Get the qsearch.options.Options object from a compilation of project
- Parameters:
name – Optionally pass the name of the compilation to get the qsearch.options.Options object from
- Returns:
the requested options object
- Return type:
- 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
- Return type:
str