| 23 | return nanobind::cast<cudaq::spin_op>(obj); |
| 24 | } |
| 25 | cudaq::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 |
no test coverage detected