Commit f228efa7 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Adding ability to print function to latex in python api using pyquil to_latex

Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <>
parent 40812853
import xacc
f = xacc.getIRGenerator('uccsd').generate([2,4])
f = f.eval([2,4])
\ No newline at end of file
......@@ -244,6 +244,8 @@ PYBIND11_MODULE(_pyxacc, m) {
.def("name", &xacc::Compiler::name, "Return the name of this Compiler.")
.def("compile", (std::shared_ptr<xacc::IR> (xacc::Compiler::*)(const std::string&, std::shared_ptr<xacc::Accelerator>)) &xacc::Compiler::compile, "Compile the "
"given source code against the given Accelerator.")
.def("compile", (std::shared_ptr<xacc::IR> (xacc::Compiler::*)(const std::string&)) &xacc::Compiler::compile, "Compile the "
"given source code.")
.def("translate", &xacc::Compiler::translate, "Translate the given IR Function instance to source code in this Compiler's language.");
// Expose the Program object
......@@ -140,6 +140,18 @@ class qpu(object):
return buf
return wrapped_f
def functionToLatex(function):
import pyquil
except ImportError:
print('Error - We delegate to Pyquil for Latex generation. Install Pyquil.')
if not hasCompiler('quil'):
print('Error - We use XACC QuilCompiler to generate Latex. Install XACC-Rigetti plugin.')
from pyquil.latex import to_latex
return to_latex(pyquil.quil.Program(getCompiler('quil').translate('',function)))
def main(argv=None):
opts = parse_args(sys.argv[1:])
xaccLocation = os.path.dirname(os.path.realpath(__file__))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment