Loading ir/transformations/NoiseAware/tests/NoiseAwareTransformationTester.cpp +29 −1 Original line number Diff line number Diff line Loading @@ -4,11 +4,39 @@ #include "XACC.hpp" #include "qcor.hpp" #include "xacc_service.hpp" #include CNOT.hpp using namespace qcor; using namespace qcor::transformations; // TEST() {} //TODO // first way const std::string uccsdSrc = R"uccsdSrc(def foo(): H(0) CNOT(0,1) )uccsdSrc"; TEST(NoiseAwareTransformationTester, checkSimple ) { if (xacc::hasCompiler("xacc-py")) { auto c = xacc::getService<xacc::Compiler>("xacc-py"); auto f = c->compile("def foo(buffer):\n H(0)\n CNOT(0,1)\n") ->getKernels()[0]; auto ir = std::make_shared<GateIR>(); ir->addKernel(f); NoiseAwareTransformation nat; auto newir = opt.transform(ir); auto natF = newir->getKernels()[0]; EXPECT_EQ(2, natF->nInstructions()); EXPECT_EQ(std::vector<int>{1}, natF->getInstruction(0)->bits()); EXPECT_EQ(std::vector<int>{0,1}, natF->getInstruction(1)->bits()); } int main(ing argc, char **argv) { qcor::Initialize(argc, argv); Loading Loading
ir/transformations/NoiseAware/tests/NoiseAwareTransformationTester.cpp +29 −1 Original line number Diff line number Diff line Loading @@ -4,11 +4,39 @@ #include "XACC.hpp" #include "qcor.hpp" #include "xacc_service.hpp" #include CNOT.hpp using namespace qcor; using namespace qcor::transformations; // TEST() {} //TODO // first way const std::string uccsdSrc = R"uccsdSrc(def foo(): H(0) CNOT(0,1) )uccsdSrc"; TEST(NoiseAwareTransformationTester, checkSimple ) { if (xacc::hasCompiler("xacc-py")) { auto c = xacc::getService<xacc::Compiler>("xacc-py"); auto f = c->compile("def foo(buffer):\n H(0)\n CNOT(0,1)\n") ->getKernels()[0]; auto ir = std::make_shared<GateIR>(); ir->addKernel(f); NoiseAwareTransformation nat; auto newir = opt.transform(ir); auto natF = newir->getKernels()[0]; EXPECT_EQ(2, natF->nInstructions()); EXPECT_EQ(std::vector<int>{1}, natF->getInstruction(0)->bits()); EXPECT_EQ(std::vector<int>{0,1}, natF->getInstruction(1)->bits()); } int main(ing argc, char **argv) { qcor::Initialize(argc, argv); Loading