Exemplo n.º 1
0
void dict_base::clear()
{
    if (check_exact(this))
        PyDict_Clear(this->ptr());
    else
        this->attr("clear")();
}
Exemplo n.º 2
0
list dict_base::items() const
{
    if (check_exact(this))
    {
        return list(detail::new_reference(
                        PyDict_Items(this->ptr())));
    }
    else
    {
        return assume_list(this->attr("items")());
    }
}
Exemplo n.º 3
0
object dict_base::get(object_cref k) const
{
    if (check_exact(this))
    {
        PyObject* result = PyDict_GetItem(this->ptr(),k.ptr());
        return object(detail::borrowed_reference(result ? result : Py_None));
    }
    else
    {
        return this->attr("get")(k);
    }
}
Exemplo n.º 4
0
void dict_base::update(object_cref other)
{
    if (check_exact(this))
    {
        if (PyDict_Update(this->ptr(),other.ptr()) == -1)
            throw_error_already_set();
    }
    else
    {
        this->attr("update")(other);
    }
}
Exemplo n.º 5
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  check_nans ();
  check_exact ();
  check_float ();

  check53("6.9314718055994530941514e-1", "0.0", MPFR_RNDZ, "0.0");
  check53("0.0", "6.9314718055994530941514e-1", MPFR_RNDZ, "0.0");
  check_sign();
  check53("-4.165000000e4", "-0.00004801920768307322868063274915", MPFR_RNDN,
          "2.0");
  check53("2.71331408349172961467e-08", "-6.72658901114033715233e-165",
          MPFR_RNDZ, "-1.8251348697787782844e-172");
  check53("2.71331408349172961467e-08", "-6.72658901114033715233e-165",
          MPFR_RNDA, "-1.8251348697787786e-172");
  check53("0.31869277231188065", "0.88642843322303122", MPFR_RNDZ,
          "2.8249833483992453642e-1");
  check("8.47622108205396074254e-01", "3.24039313247872939883e-01", MPFR_RNDU,
        28, 45, 2, "0.375");
  check("8.47622108205396074254e-01", "3.24039313247872939883e-01", MPFR_RNDA,
        28, 45, 2, "0.375");
  check("2.63978122803639081440e-01", "6.8378615379333496093e-1", MPFR_RNDN,
        34, 23, 31, "0.180504585267044603");
  check("1.0", "0.11835170935876249132", MPFR_RNDU, 6, 41, 36,
        "0.1183517093595583");
  check53("67108865.0", "134217729.0", MPFR_RNDN, "9.007199456067584e15");
  check("1.37399642157394197284e-01", "2.28877275604219221350e-01", MPFR_RNDN,
        49, 15, 32, "0.0314472340833162888");
  check("4.03160720978664954828e-01", "5.854828e-1"
        /*"5.85483042917246621073e-01"*/, MPFR_RNDZ,
        51, 22, 32, "0.2360436821472831");
  check("3.90798504668055102229e-14", "9.85394674650308388664e-04", MPFR_RNDN,
        46, 22, 12, "0.385027296503914762e-16");
  check("4.58687081072827851358e-01", "2.20543551472118792844e-01", MPFR_RNDN,
        49, 3, 2, "0.09375");
  check_max();
  check_min();

  check_regression ();
  test_generic (2, 500, 100);

  data_check ("data/mulpi", mpfr_mulpi, "mpfr_mulpi");

  valgrind20110503 ();

  tests_end_mpfr ();
  return 0;
}
Exemplo n.º 6
0
dict dict_base::copy()
{
    if (check_exact(this))
    {
        return dict(detail::new_reference(
                        PyDict_Copy(this->ptr())));
    }
    else
    {
        return dict(detail::borrowed_reference(
                        this->attr("copy")().ptr()
                        ));
    }
}