Commit 999effda authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

update to docs


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent e50e68dd
Pipeline #80041 passed with stage
in 4 minutes and 47 seconds
......@@ -673,7 +673,7 @@ To use this Observable, ensure you have Psi4 installed under the same
$ git clone https://github.com/psi4/psi4 && cd psi4 && mkdir build && cd build
$ cmake .. -DPYTHON_EXECUTABLE=$(which python3) -DCMAKE_INSTALL_PREFIX=$(python3 -m site --user-site)/psi4
$ make -j8 install
$ export PYTHONPATH=$(python3 -m site --user-site)/psi4:$PYTHONPATH
$ export PYTHONPATH=$(python3 -m site --user-site)/psi4/lib:$PYTHONPATH
This observable type takes an dictionary of options describing the
molecular geometry (key ``geometry``), the basis set (key ``basis``),
......
import xacc
import sys
import numpy as np
# Get access to the desired QPU and
# allocate some qubits to run on
......
......@@ -114,6 +114,9 @@ void bind_observable(py::module &m) {
t = xacc::getContributedService<Observable>(type, false);
}
if (!t) {
xacc::error("Invalid Observable type name " + type + ", can't find in service registry.");
}
HeterogeneousMap m;
for (auto &item : options) {
PyHeterogeneousMap2HeterogeneousMap vis(m, item.first);
......@@ -122,4 +125,21 @@ void bind_observable(py::module &m) {
t->fromOptions(m);
return t;
});
m.def("getObservable",
[](const std::string &type) -> std::shared_ptr<Observable> {
std::shared_ptr<Observable> t;
if (xacc::hasService<Observable>(type)) {
t = xacc::getService<Observable>(type, false);
} else if (xacc::hasContributedService<Observable>(type)) {
t = xacc::getContributedService<Observable>(type, false);
}
if (!t) {
xacc::error("Invalid Observable type name " + type + ", can't find in service registry.");
}
HeterogeneousMap m;
t->fromOptions(m);
return t;
});
}
\ No newline at end of file
......@@ -115,6 +115,18 @@ PYBIND11_MODULE(_pyxacc, m) {
accd->setDecorated(acc);
return accd;
});
m.def("getAcceleratorDecorator",
[](const std::string name, std::shared_ptr<Accelerator> acc, const PyHeterogeneousMap& options) {
auto accd = xacc::getService<AcceleratorDecorator>(name);
accd->setDecorated(acc);
HeterogeneousMap m;
for (auto &item : options) {
PyHeterogeneousMap2HeterogeneousMap vis(m, item.first);
mpark::visit(vis, item.second);
}
accd->initialize(m);
return accd;
});
m.def("asComposite", &xacc::ir::asComposite, "");
m.def("asInstruction", &xacc::ir::asInstruction, "");
m.def(
......
......@@ -290,7 +290,8 @@ class PyServiceRegistry(object):
def initialize(self):
serviceList = ['decorator_algorithm_service', 'benchmark_algorithm',
'hamiltonian_generator', 'ansatz_generator', 'accelerator', 'irtransformation', 'observable']
'hamiltonian_generator', 'ansatz_generator', 'accelerator',
'irtransformation', 'observable']
xaccLocation = os.path.dirname(os.path.realpath(__file__))
self.pluginDir = xaccLocation + '/py-plugins'
if not os.path.exists(self.pluginDir):
......
Markdown is supported
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