예제 #1
0
파일: sps_py.c 프로젝트: esrf-bliss/Sps
static PyObject *sps_putdatacol(PyObject *self, PyObject *args)
{
  char *spec_version, *array_name;
  int ptype, stype;
  PyObject *in_src;
  PyArrayObject *src;
  int no_items;
  int in_col = 0;


  if (!PyArg_ParseTuple(args, "ssiO", &spec_version, &array_name, &in_col,
            &in_src)) {
    return NULL;
  }

  if (!(src = (PyArrayObject*) PyArray_ContiguousFromObject(in_src,
                NPY_NOTYPE, 1, 1))) {
    struct module_state *st = GETSTATE(self);
    PyErr_SetString(st->SPSError, "Input Array is not a 1 dim array");
    return NULL;
  }

  ptype = PyArray_DESCR(src)->type_num;
  stype = sps_py2type(ptype);

  no_items = (int) PyArray_DIMS(src)[0];

  if (SPS_CopyColToShared(spec_version, array_name, PyArray_DATA(src), stype,
              in_col, no_items, NULL)
      == -1) {
    struct module_state *st = GETSTATE(self);
    PyErr_SetString(st->SPSError, "Error copying data to shared memory");
    Py_DECREF(src);
    return NULL;
  }else
   Py_DECREF(src);

  Py_INCREF(Py_None);
  return Py_None;
}
예제 #2
0
파일: sps_py.c 프로젝트: alemirone/pymca
static PyObject *sps_putdatacol(PyObject *self, PyObject *args)
{
  char *spec_version, *array_name;
  int ptype, stype;
  PyObject *in_src;
  PyArrayObject *src;
  int no_items;
  int in_col = 0;


  if (!PyArg_ParseTuple(args, "ssiO", &spec_version, &array_name, &in_col,
            &in_src)) {
    return NULL;
  }

  if (!(src = (PyArrayObject*) PyArray_ContiguousFromObject(in_src,
                PyArray_NOTYPE, 1, 1))) {
    PyErr_SetString(SPSError, "Input Array is not a 1 dim array");
    return NULL;
  }

  ptype = src->descr->type_num;
  stype = sps_py2type(ptype);

  no_items = src->dimensions[0];

  if (SPS_CopyColToShared(spec_version, array_name, src->data, stype,
              in_col, no_items, NULL)
      == -1) {
    PyErr_SetString(SPSError, "Error copying data to shared memory");
    Py_DECREF(src);
    return NULL;
  }else
   Py_DECREF(src);

  Py_INCREF(Py_None);
  return Py_None;
}