Skip to content

Commit

Permalink
add concatenate_descriotion() to gate.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Glacialte committed Jan 28, 2025
1 parent cbae27d commit b70955f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
19 changes: 11 additions & 8 deletions include/scaluq/gate/gate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,17 @@ namespace internal {
template <std::floating_point Fp>
nb::class_<Gate<Fp>> gate_base_def;

#define DEF_GATE(GATE_TYPE, FLOAT, DESCRIPTION) \
::scaluq::internal::gate_base_def<FLOAT>.def(nb::init<GATE_TYPE<FLOAT>>(), \
"Upcast from `" #GATE_TYPE "`."); \
DEF_GATE_BASE( \
GATE_TYPE, \
FLOAT, \
DESCRIPTION \
"\n\n.. note:: Upcast is required to use gate-general functions (ex: add to Circuit).") \
inline nb::sig concatenate_description(const std::string& desc) {
std::string combined =
desc +
"\n\n.. note:: Upcast is required to use gate-general functions (ex: add to Circuit).";
return nb::sig(combined.c_str());
}

#define DEF_GATE(GATE_TYPE, FLOAT, DESCRIPTION) \
::scaluq::internal::gate_base_def<FLOAT>.def(nb::init<GATE_TYPE<FLOAT>>(), \
"Upcast from `" #GATE_TYPE "`."); \
DEF_GATE_BASE(GATE_TYPE, FLOAT, concatenate_description(DESCRIPTION)) \
.def(nb::init<Gate<FLOAT>>())

void bind_gate_gate_hpp_without_precision(nb::module_& m) {
Expand Down
5 changes: 0 additions & 5 deletions include/scaluq/operator/pauli_operator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ void bind_operator_pauli_operator_hpp(nb::module_& m) {
.value("PAULI_Y", PauliOperator<Fp>::PAULI_Y)
.value("PAULI_Z", PauliOperator<Fp>::PAULI_Z);

// m.attr("PAULI_I") = (int)PauliOperator<Fp>::PAULI_I;
// m.attr("PAULI_X") = (int)PauliOperator<Fp>::PAULI_X;
// m.attr("PAULI_Y") = (int)PauliOperator<Fp>::PAULI_Y;
// m.attr("PAULI_Z") = (int)PauliOperator<Fp>::PAULI_Z;

nb::class_<typename PauliOperator<Fp>::Data>(
m, "PauliOperatorData", "Internal data structure for PauliOperator.")
.def(nb::init<Complex<Fp>>(), "coef"_a = 1., "Initialize data with coefficient.")
Expand Down

0 comments on commit b70955f

Please sign in to comment.