Example #1
0
void check_compare_y_at_x_left()
{
  Polycurve_conic_traits_2 traits;
  Polycurve_conic_traits_2::Construct_x_monotone_curve_2
    construct_x_monotone_curve_2 = traits.construct_x_monotone_curve_2_object();
  Polycurve_conic_traits_2::Compare_y_at_x_left_2 cmp_y_at_x_left_2 =
    traits.compare_y_at_x_left_2_object();

  //create constructing curves
  Rat_point_2 ps2(1, 10);
  Rat_point_2 pmid2(5, 4);
  Rat_point_2 pt2(10, 1);
  Conic_curve_2 c1(ps2, pmid2, pt2);

  Rat_point_2 ps3(10, 1);
  Rat_point_2 pmid3(5, 4);
  Rat_point_2 pt3(1, 10);
  Conic_curve_2 c2(ps3, pmid3, pt3);

  //construct x-monotone curve(compatible with polyline class)
  Polycurve_conic_traits_2::X_monotone_curve_2 polyline_xmc1 =
    construct_x_monotone_curve_2(c1);
  Polycurve_conic_traits_2::X_monotone_curve_2 polyline_xmc2 =
    construct_x_monotone_curve_2(c2);
  Polycurve_conic_traits_2::Point_2 intersection_point =
    Polycurve_conic_traits_2::Point_2(5,4);

  CGAL::Comparison_result result;

  result = cmp_y_at_x_left_2(polyline_xmc1, polyline_xmc2, intersection_point);
  std::cout << "Compare_y_at_x_left:: Expected Answer: equal, Computed answer:  "
            << (result == CGAL::SMALLER ? "smaller":
               (result == CGAL::LARGER ? "Larger" : "equal")) << std::endl;
}
Example #2
0
int main()
{
	HasPtr ps1("This is a string"), ps3("This is another string");
	HasPtr ps2 = ps1;
	ps2 = ps3;
	return 0;
}
Example #3
0
void array_var_bool_element(IntVar* _x, vec<BoolView>& a, BoolView y, int offset) {
	_x->specialiseToEL();
	IntView<4> x(_x, 1, -offset);
	vec<Lit> ps1(a.size()+1);
	vec<Lit> ps2(a.size()+1);
	// Add clause !y \/ c_1 \/ ... \/ c_n
	// Add clause y \/ d_1 \/ ... \/ d_n
	ps1[0] = ~y;
	ps2[0] = y;
	for (int i = 0; i < a.size(); i++) {
		BoolView c_i(Lit(sat.newVar(),1));
		BoolView d_i(Lit(sat.newVar(),1));
		sat.addClause(~c_i, x = i);
		sat.addClause(~c_i, a[i]);
		sat.addClause(~d_i, x = i);
		sat.addClause(~d_i, ~a[i]);
		vec<Lit> ps3(3), ps4(3);
		ps3[0] = y; ps3[1] = ~a[i]; ps3[2] = (x != i);
		sat.addClause(ps3);
		ps4[0] = ~y; ps4[1] = a[i]; ps4[2] = (x != i);
		sat.addClause(ps4);
		ps1[i+1] = c_i;
		ps2[i+1] = d_i;
	}
	sat.addClause(ps1);
	sat.addClause(ps2);
}
Example #4
0
int main(void)
{
	long long int time=0;
	Led0 led;Blink blink0(led);blink0.setup();blink0.time(100);
	A0 a0;Blink blink1(a0);blink1.setup();blink1.time(100);
	Serial0 serial;serial.setup(115200);

	Serial1 serial1;
	Enc0 l;Enc1 r;Enc2 b;
	RobotCenter center(l,r,b);center.setup();
	Can0 can;
	DualShock ps3(serial1);
	ps3.setStickTolerance(0.1);
	//DualShock ps3(serial1);ps3.setup();
	/*Cw4 cw4;Ccw4 ccw4;Pwm4 pwm4;Md md4(cw4,ccw4,pwm4);
	Cw5 cw5;Ccw5 ccw5;Pwm5 pwm5;Md md5(cw5,ccw5,pwm5);
	Cw6 cw6;Ccw6 ccw6;Pwm6 pwm6;Md md6(cw6,ccw6,pwm6);
	Cw7 cw7;Ccw7 ccw7;Pwm7 pwm7;Md md7(cw7,ccw7,pwm7);*/
	CW0 cw4;CCW0 ccw4;Pwm0 pwm4;Md md4(cw4,ccw4,pwm4);
	CW1 cw5;CCW1 ccw5;Pwm1 pwm5;Md md5(cw5,ccw5,pwm5);
	CW2 cw6;CCW2 ccw6;Pwm2 pwm6;Md md6(cw6,ccw6,pwm6);
	CW3 cw7;CCW3 ccw7;Pwm3 pwm7;Md md7(cw7,ccw7,pwm7);
	Move move(md4,md5,md6,md7,center,ps3);move.setup();
	Debug debug(serial,center,ps3);debug.setup();

	while(1){
		blink0.cycle();
		center.cycle();
		ps3.cycle();
		//move.manualModeCycle();
		debug.cycle();

		if(millis()-time>=100){
			time=millis();
			/*serial.printf("lx:%.4f",ps3.lx());
			serial.printf("ly:%.4f",ps3.ly());
			serial.printf("rx:%.4f",ps3.rx());
			serial.printf("ry:%.4f",ps3.ry());
			serial.printf("u:%.4f",ps3.up());
			serial.printf("r:%.4f",ps3.right());
			serial.printf("d:%.4f",ps3.down());
			serial.printf("l:%.4f",ps3.left());
			serial.printf("tri:%.4f",ps3.triangle());
			serial.printf("cir:%.4f",ps3.circle());
			serial.printf("cro:%.4f",ps3.cross());
			serial.printf("squ:%.4f",ps3.square());
			serial.printf("l1:%.4f",ps3.l1());
			serial.printf("l2:%.4f",ps3.l2());
			serial.printf("r1:%.4f",ps3.r1());
			serial.printf("r2:%.4f",ps3.r2());
			serial.printf("start:%.4f",ps3.start());
			serial.printf("select:%.4f",ps3.select());
			serial.printf("dis:%d\n",ps3.disconnect());*/

			//serial.printf("ang,% .4f, x,% .4f, y,% .4f\n",rtod(center.getAngle()),center.x(),center.y());
		}
	}
	return 0;
}
Example #5
0
void check_equal()
{
  bool are_equal;

  Polycurve_conic_traits_2 traits;
  Polycurve_conic_traits_2::Equal_2 equal = traits.equal_2_object();
  Polycurve_conic_traits_2::Construct_x_monotone_curve_2
    construct_x_monotone_curve_2 = traits.construct_x_monotone_curve_2_object();

  //create some curves
  Conic_point_2 ps1(Rational(1,4), 4);
  Conic_point_2 pt1(2, Rational(1,2));
  Conic_curve_2 c1(0, 0, 1, 0, 0, -1, CGAL::COUNTERCLOCKWISE, ps1, pt1);

  Conic_point_2 ps2(Rational(1,4), 4);
  Conic_point_2 pt2(2, Rational(1,2));
  Conic_curve_2 c2(0, 0, 1, 0, 0, -1, CGAL::COUNTERCLOCKWISE, ps2, pt2);

  Rat_point_2 ps3(Rational(1,4), 4);
  Rat_point_2 pmid3(Rational(3,2), 2);
  Rat_point_2 pt3(2, Rational(1,3));
  Conic_curve_2 c3(ps3, pmid3, pt3);

  Rat_point_2 ps4(1, 5);
  Rat_point_2 pmid4(Rational(3,2), 3);
  Rat_point_2 pt4(3, Rational(1,3));
  Conic_curve_2 c4(ps4, pmid4, pt4);

  // //make x_monotone
  Polycurve_conic_traits_2::X_monotone_curve_2 xmc1 =
    construct_x_monotone_curve_2(c1);
  Polycurve_conic_traits_2::X_monotone_curve_2 xmc2 =
    construct_x_monotone_curve_2(c2);
  Polycurve_conic_traits_2::X_monotone_curve_2 xmc3 =
    construct_x_monotone_curve_2(c3);
  Polycurve_conic_traits_2::X_monotone_curve_2 xmc4 =
    construct_x_monotone_curve_2(c4);

  are_equal = equal(xmc1, xmc2);
  std::cout << "Two equal conic arcs are computed as:  "
            << ((are_equal) ? "equal" : "Not equal") << std::endl;

  are_equal = equal(xmc3, xmc2);
  std::cout << "Two un-equal conic arcs are computed as:  "
            << ((are_equal) ? "equal" : "Not equal") << std::endl;

  are_equal = equal(xmc3, xmc4);
  std::cout << "Two un-equal conic arcs are computed as:  "
            << ((are_equal) ? "equal" : "Not equal") << std::endl;
 }
void ClientConnection::RestoreArea(RECT &r)
{
	int x = r.left;
	int y = r.top;
	int w = r.right - r.left;
	int h = r.bottom - r.top;
	HBITMAP m_hTempBitmap=NULL;
	HDC		m_hTempBitmapDC=NULL;

	boost::recursive_mutex::scoped_lock l(m_bitmapdcMutex);

	ObjectSelector b1(m_hBitmapDC, m_hBitmap);
	PaletteSelector ps1(m_hBitmapDC, m_hPalette);
	m_hTempBitmapDC = CreateCompatibleDC(m_hBitmapDC);
	m_hTempBitmap = CreateCompatibleBitmap(m_hBitmapDC, w, h);
	ObjectSelector b3(m_hTempBitmapDC, m_hTempBitmap);
	PaletteSelector ps3(m_hTempBitmapDC, m_hPalette);
	ObjectSelector b2(m_hCacheBitmapDC, m_hCacheBitmap);
	PaletteSelector ps2(m_hCacheBitmapDC, m_hPalette);

	if (!BitBlt(m_hTempBitmapDC, 0, 0, w, h, m_hBitmapDC, x, y, SRCCOPY)) 
	{
		//vnclog.Print(0, _T("Error saving temp bitmap\n"));
		Log.WinError(_ERROR_, "Error saving temp bitmap");
	}

	if (!BitBlt(m_hBitmapDC, x, y, w, h, m_hCacheBitmapDC, x, y, SRCCOPY)) 
	{
		//vnclog.Print(0, _T("Error restoring screen\n"));
		Log.WinError(_ERROR_, "Error restoring screen");
	}

	if (!BitBlt(m_hCacheBitmapDC, x, y, w, h, m_hTempBitmapDC, 0, 0, SRCCOPY)) 
	{
		//vnclog.Print(0, _T("Error restoring screen under cursor\n"));
		Log.WinError(_ERROR_, "Error restoring screen under cursor");
	}

	DeleteDC(m_hTempBitmapDC);
	if (m_hTempBitmap != NULL)
		DeleteObject(m_hTempBitmap);
	if (m_hCacheBitmapDC != NULL)
		DeleteObject(m_hTempBitmapDC);
}
Example #7
0
void check_are_mergable()
{
  Polycurve_conic_traits_2 traits;
  Polycurve_conic_traits_2::Construct_x_monotone_curve_2
    construct_x_monotone_curve_2 = traits.construct_x_monotone_curve_2_object();
  Polycurve_conic_traits_2::Are_mergeable_2  are_mergeable_2 =
    traits.are_mergeable_2_object();

   //create a curve
  Rat_point_2 ps1(1, 10);
  Rat_point_2 pmid1(5, 4);
  Rat_point_2 pt1(10, 1);
  Conic_curve_2 c1(ps1, pmid1, pt1);

  Rat_point_2 ps2(10, 1);
  Rat_point_2 pmid2(15, 14);
  Rat_point_2 pt2(20, 20);
  Conic_curve_2 c2(ps2, pmid2, pt2);

  Rat_point_2 ps3(Rational(1,4), 4);
  Rat_point_2 pmid3(Rational(3,2), 2);
  Rat_point_2 pt3(2, Rational(1,3));
  Conic_curve_2 c3(ps3, pmid3, pt3);

  //construct x-monotone curve(compatible with polyline class)
   Polycurve_conic_traits_2::X_monotone_curve_2 polyline_xmc1 =
     construct_x_monotone_curve_2(c1);
   Polycurve_conic_traits_2::X_monotone_curve_2 polyline_xmc2 =
     construct_x_monotone_curve_2(c2);
   Polycurve_conic_traits_2::X_monotone_curve_2 polyline_xmc3 =
     construct_x_monotone_curve_2(c3);

  bool result = are_mergeable_2(polyline_xmc1, polyline_xmc2);
  std::cout << "Are_mergable:: Mergable x-monotone polycurves are Computed as: "
            << ((result)? "Mergable" : "Not-Mergable") << std::endl;

  result = are_mergeable_2(polyline_xmc1, polyline_xmc3);
  std::cout << "Are_mergable:: Non-Mergable x-monotone polycurves are Computed as: "
            << ((result)? "Mergable" : "Not-Mergable") << std::endl;
}
Example #8
0
void EGS_TrackView::setProjection(EGS_Vector pxo, EGS_Vector px_screen, EGS_Vector pv1_screen,
    EGS_Vector pv2_screen, EGS_Float psx, EGS_Float psy) {

    // set camera and screen variables
    xo = pxo;
    sx = psx;
    sy = psy;
    x_screen = px_screen;
    v1_screen = pv1_screen;
    v2_screen = pv2_screen;
    v1_screen.normalize();
    v2_screen.normalize();

    // calculate the equation of the projection plane defined by the screen:
    //      a*x + b*y + c*z = 1
    EGS_Vector ps1(x_screen);
    EGS_Vector ps2(x_screen + v1_screen);
    EGS_Vector ps3(x_screen + v2_screen);
    double d = det(ps1, ps2, ps3);
    EGS_Vector a1 = ps1; a1.x = 1;
    EGS_Vector a2 = ps2; a2.x = 1;
    EGS_Vector a3 = ps3; a3.x = 1;
    double d1 = det(a1, a2, a3);
    EGS_Vector b1 = ps1; b1.y = 1;
    EGS_Vector b2 = ps2; b2.y = 1;
    EGS_Vector b3 = ps3; b3.y = 1;
    double d2 = det(b1, b2, b3);
    EGS_Vector c1 = ps1; c1.z = 1;
    EGS_Vector c2 = ps2; c2.z = 1;
    EGS_Vector c3 = ps3; c3.z = 1;
    double d3 = det(c1, c2, c3);

    // avoid seg faults
    if (d == 0.0000) d += 0.001;
    m_scr_a = d1/d;
    m_scr_b = d2/d;
    m_scr_c = d3/d;
};
Example #9
0
void PyHelpersTest::RunTests()
{
  // Test py::Ptr construction
  {
    {
      // NULL pointer
      PyObject * p  = NULL;
      SHOULDFAIL(py::Ptr(p, /* allowNULL: */false));

      py::Ptr pp1(p, /* allowNULL: */true);
      TEST((PyObject *)pp1 == NULL);
      TEST(pp1.isNULL());
    }

    // Non-NULL pointer
    {
      PyObject * p = PyTuple_New(1);
      py::Ptr pp2(p);
      TEST(!pp2.isNULL());
      TEST((PyObject *)pp2 == p);
      pp2.release();
      TEST(pp2.isNULL());
      Py_DECREF(p);
    }
    
    // assign
    {
      PyObject * p = PyTuple_New(1);
      TEST(p->ob_refcnt == 1);
      py::Ptr pp(NULL, /* allowNULL */ true);
      TEST(pp.isNULL());
      NTA_DEBUG << "*** Before assign";
      pp.assign(p);
      NTA_DEBUG << "*** After assign";
      TEST(p->ob_refcnt == 2);
      TEST(!(pp.isNULL()));
      Py_DECREF(p);
      TEST(p->ob_refcnt == 1);
    }
  }

  // py::String
  {
    py::String ps1(std::string("123"));
    TEST(PyString_Check(ps1) != 0);

    py::String ps2("123", size_t(3));
    TEST(PyString_Check(ps2) != 0);

    py::String ps3("123");
    TEST(PyString_Check(ps3) != 0);

    std::string s1(PyString_AsString(ps1));
    std::string s2(PyString_AsString(ps2));
    std::string s3(PyString_AsString(ps3));
    std::string expected("123");
    TEST(s1 == expected);
    TEST(s2 == expected);
    TEST(s3 == expected);
  
    TEST(std::string(ps1) == expected);
    TEST(std::string(ps2) == expected);
    TEST(std::string(ps3) == expected);

    PyObject * p = PyString_FromString("777");
    py::String ps4(p);
    TEST(std::string(ps4) == std::string("777"));
  }

  // py::Int
  {
    py::Int n1(-5);
    py::Int n2(-6666);
    py::Int n3(long(0));
    py::Int n4(555);
    py::Int n5(6666);
    
    TEST(n1 == -5);
    int x = n2; 
    int expected = -6666;
    TEST(x == expected);
    TEST(n3 == 0);
    TEST(n4 == 555);
    x = n5;
    expected = 6666;
    TEST(x == expected);
  }

  // py::Long
  {
    py::Long n1(-5);
    py::Long n2(-66666666);
    py::Long n3(long(0));
    py::Long n4(555);
    py::Long n5(66666666);
    
    TEST(n1 == -5);
    long x = n2; 
    long expected = -66666666;
    TEST(x == expected);
    TEST(n3 == 0);
    TEST(n4 == 555);
    x = n5;
    expected = 66666666;
    TEST(x == expected);
  }

  // py::UnsignedLong
  {
    py::UnsignedLong n1((unsigned long)(-5));
    py::UnsignedLong n2((unsigned long)(-66666666));
    py::UnsignedLong n3((unsigned long)(0));
    py::UnsignedLong n4(555);
    py::UnsignedLong n5(66666666);
    
    TEST(n1 == (unsigned long)(-5));
    TEST(n2 == (unsigned long)(-66666666));
    TEST(n3 == 0);
    TEST(n4 == 555);
    TEST(n5 == 66666666);
  }

  // py::Float
  {
    TEST(py::Float::getMax() == std::numeric_limits<double>::max());
    TEST(py::Float::getMin() == std::numeric_limits<double>::min());

    py::Float max(std::numeric_limits<double>::max());
    py::Float min(std::numeric_limits<double>::min());
    py::Float n1(-0.5);
    py::Float n2(double(0));
    py::Float n3(333.555);
    py::Float n4(0.02);
    py::Float n5("0.02");
    
    TEST(max == py::Float::getMax());
    TEST(min == py::Float::getMin());
    TEST(n1 == -0.5);
    TEST(n2 == 0);
    TEST(n3 == 333.555);
    TEST(n4 == 0.02);
    TEST(n5 == 0.02);
  }

  // py::Tuple
  {
    py::String s1("item_1");
    py::String s2("item_2");

    // Empty tuple
    {
      py::Tuple empty;
      TEST(PyTuple_Check(empty) != 0);
      TEST(empty.getCount() == 0);
      
      SHOULDFAIL(empty.setItem(0, s1));
      SHOULDFAIL(empty.getItem(0));
    }

    // One item tuple
    {
      py::Tuple t1(1);
      TEST(PyTuple_Check(t1) != 0);
      TEST(t1.getCount() == 1);

      t1.setItem(0, s1);
      py::String item1(t1.getItem(0));
      TEST(std::string(item1) == std::string(s1));
      
      py::String fastItem1(t1.fastGetItem(0));
      TEST(std::string(fastItem1) == std::string(s1));
      fastItem1.release();
      
      SHOULDFAIL(t1.setItem(1, s2));
      SHOULDFAIL(t1.getItem(1));

      TEST(t1.getCount() == 1);
    }

    // 2 items tuple
    {
      py::Tuple t2(2);
      TEST(PyTuple_Check(t2) != 0);
      TEST(t2.getCount() == 2);

      t2.setItem(0, s1);
      py::String item1(t2.getItem(0));
      TEST(std::string(item1) == std::string(s1));
      py::String fastItem1(t2.fastGetItem(0));
      TEST(std::string(fastItem1) == std::string(s1));
      fastItem1.release();

      t2.setItem(1, s2);
      py::String item2(t2.getItem(1));
      TEST(std::string(item2) == std::string(s2));
      py::String fastItem2(t2.fastGetItem(1));
      TEST(std::string(fastItem2) == std::string(s2));
      fastItem2.release();


      SHOULDFAIL(t2.setItem(2, s2));
      SHOULDFAIL(t2.getItem(2));

      TEST(t2.getCount() == 2);
    }
  }

  // py::List
  {
    py::String s1("item_1");
    py::String s2("item_2");

    // Empty list
    {
      py::List empty;
      TEST(PyList_Check(empty) != 0);
      TEST(empty.getCount() == 0);
      
      SHOULDFAIL(empty.setItem(0, s1));
      SHOULDFAIL(empty.getItem(0));
    }

    // One item list
    {
      py::List t1;
      TEST(PyList_Check(t1) != 0);
      TEST(t1.getCount() == 0);

      t1.append(s1);
      py::String item1(t1.getItem(0));
      TEST(std::string(item1) == std::string(s1));
      py::String fastItem1(t1.fastGetItem(0));
      TEST(std::string(fastItem1) == std::string(s1));
      fastItem1.release();

      TEST(t1.getCount() == 1);
      TEST(std::string(item1) == std::string(s1));
      
      SHOULDFAIL(t1.getItem(1));
    }

    // Two items list
    {
      py::List t2;
      TEST(PyList_Check(t2) != 0);
      TEST(t2.getCount() == 0);

      t2.append(s1);
      py::String item1(t2.getItem(0));
      TEST(std::string(item1) == std::string(s1));
      py::String fastItem1(t2.fastGetItem(0));
      TEST(std::string(fastItem1) == std::string(s1));
      fastItem1.release();

      t2.append(s2);
      TEST(t2.getCount() == 2);
      
      py::String item2(t2.getItem(1));
      TEST(std::string(item2) == std::string(s2));
      py::String fastItem2(t2.fastGetItem(1));
      TEST(std::string(fastItem2) == std::string(s2));
      fastItem2.release();


      SHOULDFAIL(t2.getItem(2));
    }
  }

  // py::Dict
  {
    // Empty dict
    {
      py::Dict d;
      TEST(PyDict_Size(d) == 0);

      TEST(d.getItem("blah") == NULL);
    }

    // Failed External PyObject *
    {
      // NULL object
      SHOULDFAIL(py::Dict(NULL));

      // Wrong type (must be a dictionary)
      py::String s("1234");
      try
      {
        py::Dict d(s.release());
        NTA_THROW << "py::Dict d(s) Should fail!!!";
      }
      catch(...)
      {
      }
      // SHOULDFAIL fails to fail :-)
      //SHOULDFAIL(py::Dict(s));
    }

    // Successful external PyObject *
    {

      PyObject * p = PyDict_New();
      PyDict_SetItem(p, py::String("1234"), py::String("5678"));
      
      py::Dict d(p);

      TEST(PyDict_Contains(d, py::String("1234")) == 1);

      PyDict_SetItem(d, py::String("777"), py::String("999"));

      TEST(PyDict_Contains(d, py::String("777")) == 1);

    }
    
    // getItem with default (exisiting and non-exisitng key)
    {
      py::Dict d;
      d.setItem("A", py::String("AAA"));

      PyObject * defaultItem = (PyObject *)123;
      
      py::String A(d.getItem("A"));             
      TEST(std::string(A) == std::string("AAA"));

      // No "B" in the dict, so expect to get the default item
      PyObject * B = (d.getItem("B", defaultItem));
      TEST(B == defaultItem);

      PyDict_SetItem(d, py::String("777"), py::String("999"));
      TEST(PyDict_Contains(d, py::String("777")) == 1);
    }
    
    
    //NTA_DEBUG << ss << ": " << ss->ob_refcnt;
  }

  // py::Module
  {
    py::Module module("sys");
    TEST(std::string(PyModule_GetName(module)) == std::string("sys"));
  }

  // py::Class
  {
    py::Class c("datetime", "date");
  }

  // py::Instance
  {
    
    py::Tuple args(3);
    args.setItem(0, py::Long(2000));
    args.setItem(1, py::Long(11));
    args.setItem(2, py::Long(5));
    py::Instance date("datetime", "date", args, py::Dict());

    // Test invoke()
    {
      py::String result(date.invoke("__str__", py::Tuple(), py::Dict()));
      std::string res((const char *)result);
      std::string expected("2000-11-05");
      TEST(res == expected);
    }

    // Test hasAttr()
    {
      py::String result(date.invoke("__str__", py::Tuple(), py::Dict()));
      std::string res((const char *)result);
      std::string expected("2000-11-05");
      TEST(!(date.hasAttr("No such attribute")));
      TEST(date.hasAttr("year"));
    }

    // Test getAttr()
    {
      py::Int year(date.getAttr("year"));
      TEST(2000 == long(year));
    }

    // Test toString()
    {
      std::string res((const char *)py::String(date.toString()));
      std::string expected("2000-11-05");
      TEST(res == expected);
    }
  }

  // Test custom exception
  {
    py::Tuple args(1);
    args.setItem(0, py::String("error message!"));
    py::Instance e(PyExc_RuntimeError, args);
    e.setAttr("traceback", py::String("traceback!!!"));

    PyErr_SetObject(PyExc_RuntimeError, e);

    try
    {
      py::checkPyError(0);
    }
    catch (const nta::Exception & e)
    {
      NTA_DEBUG << e.getMessage();
    }
  }
}