Update headers, fix style for some py files
[alexxy/gromacs.git] / src / python / include / numpy_conv.h
index 8244c177718ed185ea3a7a7b8e5791d6f42be6a5..3c7c5674cae14b497a92853d7a32070a25b7f9b0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 #include <Python.h>
 #include <numpy/ndarrayobject.h>
 
-PyObject* array2dToNumpy(int dim1, int dim2, void *data) {
+PyObject* array2dToNumpy(int dim1, int dim2, const void *data)
+{
     npy_intp dims[] = {dim1, dim2};
     #ifdef GMX_DOUBLE
-        return PyArray_SimpleNewFromData(2, dims, NPY_DOUBLE, (double*) data);
+    return PyArray_SimpleNewFromData(2, dims, NPY_DOUBLE, (double*) data);
     #else
-        return PyArray_SimpleNewFromData(2, dims, NPY_FLOAT, (float*) data);
+    return PyArray_SimpleNewFromData(2, dims, NPY_FLOAT, (float*) data);
     #endif
 }
 
-PyObject* array1dToNumpy(int dim, void *data) {
+PyObject* array1dToNumpy(int dim, const void *data)
+{
     npy_intp n_dim = dim;
     #ifdef GMX_DOUBLE
-        return PyArray_SimpleNewFromData(1, &n_dim, NPY_DOUBLE, (double*) data);
+    return PyArray_SimpleNewFromData(1, &n_dim, NPY_DOUBLE, (double*) data);
     #else
-        return PyArray_SimpleNewFromData(1, &n_dim, NPY_FLOAT, (float*) data);
+    return PyArray_SimpleNewFromData(1, &n_dim, NPY_FLOAT, (float*) data);
     #endif
 }
+
+PyObject* iarray1dToNumpy(int dim, const int *data)
+{
+    npy_intp n_dim = dim;
+    return PyArray_SimpleNewFromData(1, &n_dim, NPY_INT, (int*) data);
+}
 #endif