MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / to_spin_op_term

Function to_spin_op_term

python/runtime/common/py_ObserveResult.cpp:25–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 return nanobind::cast<cudaq::spin_op>(obj);
24}
25cudaq::spin_op to_spin_op_term(nanobind::object &obj) {
26 auto op = cudaq::spin_op::empty();
27 if (nanobind::hasattr(obj, "_to_spinop"))
28 op = nanobind::cast<cudaq::spin_op>(obj.attr("_to_spinop")());
29 else
30 op = nanobind::cast<cudaq::spin_op>(obj);
31 if (op.num_terms() != 1)
32 throw std::invalid_argument("expecting a spin op with a single term");
33 return *op.begin();
34}
35} // namespace
36
37// FIXME: add proper deprecation warnings to the bindings

Callers 1

bindObserveResultFunction · 0.85

Calls 3

emptyFunction · 0.50
num_termsMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected