Commit 76c7a7f7 authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

change numpy dimension type to unsigned int

parent 0602c9bb
......@@ -28,20 +28,30 @@
import_array();
%}
// below we change the type of dimension of numpy array.
// By default it's an "int", but we have std::vector object returning size()
// method as dimension, and which are of type "unsigned int"
// This may cause a problem with BIG simulations. Indeed a simulation with 1.1 billions particles
// store in a xyz positions array a size of 3.3 billions which overtake size of SIGNED int, which go
// only to 2^31 bits = 2.14 billons !!!!! (damn nasty bug....)
%numpy_typemaps(double, NPY_DOUBLE, unsigned int)
%numpy_typemaps(float , NPY_FLOAT , unsigned int)
%numpy_typemaps(int , NPY_INT , unsigned int)
// getArrayX return 1D numpy float array
%apply ( int* DIM1, float ** ARGOUTVIEW_ARRAY1 )
{( int* size, float ** farray )};
%apply (unsigned int* DIM1, float ** ARGOUTVIEW_ARRAY1 )
{( unsigned int* size, float ** farray )};
//%apply ( int* DIM1, int ** ARGOUTVIEW_ARRAY1 )
// {( int* size, int ** iarray )};
// getArrayX return 1D numpy double array
%apply ( int* DIM1, double ** ARGOUTVIEW_ARRAY1 )
{( int* size, double ** farray )};
%apply (unsigned int* DIM1, double ** ARGOUTVIEW_ARRAY1 )
{( unsigned int* size, double ** farray )};
// getArrayX return 1D numpy int array
%apply ( int* DIM1, int ** ARGOUTVIEW_ARRAY1 )
{( int* size, int ** iarray )};
%apply (unsigned int* DIM1, int ** ARGOUTVIEW_ARRAY1 )
{( unsigned int* size, int ** iarray )};
// getValueX return float/double/int value
......@@ -56,35 +66,35 @@
//float
%rename(getValueF) getData(const std::string,float *);
%rename(getArrayF) getData(const std::string,const std::string,int *,float **);
%rename(getArrayF) getData(const std::string,int *,float **);
%rename(getArrayF) getData(const std::string,const std::string,unsigned int *,float **);
%rename(getArrayF) getData(const std::string,unsigned int *,float **);
//double
%rename(getValueF) getData(const std::string,double *);
%rename(getArrayF) getData(const std::string,const std::string,int *,double **);
%rename(getArrayF) getData(const std::string,int *, double **);
%rename(getArrayF) getData(const std::string,const std::string,unsigned int *,double **);
%rename(getArrayF) getData(const std::string,unsigned int *, double **);
//int
%rename(getValueI) getData(const std::string,int *);
%rename(getArrayI) getData(const std::string,const std::string,int *,int **);
%rename(getArrayI) getData(const std::string,int *,int **);
%rename(getArrayI) getData(const std::string,const std::string,unsigned int *,int **);
%rename(getArrayI) getData(const std::string,unsigned int *,int **);
%apply (int DIM1 , float * INPLACE_ARRAY1) {( int size, float * farray)};
%apply (int DIM1 , double* INPLACE_ARRAY1) {( int size, double* farray)};
%apply (int DIM1 , int * INPLACE_ARRAY1) {( int size, int * iarray)};
%apply (unsigned int DIM1 , float * INPLACE_ARRAY1) {(unsigned int size, float * farray)};
%apply (unsigned int DIM1 , double* INPLACE_ARRAY1) {(unsigned int size, double* farray)};
%apply (unsigned int DIM1 , int * INPLACE_ARRAY1) {(unsigned int size, int * iarray)};
// rename methods because of overloading limitations with swig c++
// float
%rename(setValueF) setData(const std::string,float);
%rename(setArrayF_do_not_used) setData(const std::string,const std::string,int ,float *,const bool _addr=false);
%rename(setArrayF_do_not_used) setData(const std::string,int ,float *,const bool _addr=false);
%rename(setArrayF_do_not_used) setData(const std::string,const std::string,unsigned int ,float *,const bool _addr=false);
%rename(setArrayF_do_not_used) setData(const std::string,unsigned int ,float *,const bool _addr=false);
// double
%rename(setValueF) setData(const std::string,double);
%rename(setArrayF_do_not_used) setData(const std::string,const std::string,int ,double *,const bool _addr=false);
%rename(setArrayF_do_not_used) setData(const std::string,int ,double *,const bool _addr=false);
%rename(setArrayF_do_not_used) setData(const std::string,const std::string, unsigned int ,double *,const bool _addr=false);
%rename(setArrayF_do_not_used) setData(const std::string,unsigned int ,double *,const bool _addr=false);
// int
%rename(setValueI) setData(const std::string,int,const bool _addr=false);
%rename(setArrayI) setData(const std::string,const std::string,int ,int *,const bool _addr=false);
%rename(setArrayI) setData(const std::string,int ,int *);
%rename(setArrayI) setData(const std::string,const std::string,unsigned int ,int *,const bool _addr=false);
%rename(setArrayI) setData(const std::string,unsigned int ,int *);
// Parse the original header file
%include "uns.h"
......@@ -92,14 +102,14 @@
%extend uns::CunsOut2 {
// we rewrite setArrayF because numpy array size is different from nbody for 3D arrays
int setArrayF(const std::string comp,const std::string prop,
int size,T * farray, const bool _addr=false) {
unsigned int size,T * farray, const bool _addr=false) {
if (prop=="pos" || prop=="vel" || prop=="acc") size /= 3;
int status = $self->snapshot->setData(comp,prop,size,farray,_addr);
return status;
}
// we rewrite setArrayF because numpy array size is different from nbody for 3D arrays
int setArrayF(const std::string prop,
int size,T * farray, const bool _addr=false) {
unsigned int size,T * farray, const bool _addr=false) {
if (prop=="pos" || prop=="vel" || prop=="acc") size /= 3;
int status = $self->snapshot->setData(prop,size,farray,_addr);
return status;
......
......@@ -273,7 +273,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
// allocate work arrays
ngrida=ngridfile[ilevel][icpu];
if (verbose) {
std::cerr << "ngrida="<<ngrida<<" nvarg="<<nvarg<<"\n";
//std::cerr << "ngrida="<<ngrida<<" nvarg="<<nvarg<<"\n";
}
double * xg=NULL, *var=NULL, *varg=NULL;
int * son=NULL;
......
......@@ -185,7 +185,7 @@ template <class T> int CunsIn2<T>::nextFrame(const char * _bits) {
// ----------------------------------------------------------------------------
// getData
template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::string prop,
int * size,T ** farray) {
unsigned int * size,T ** farray) {
T * data=NULL;
int nbody=0;
*size=0;
......@@ -201,7 +201,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::s
// ----------------------------------------------------------------------------
// getData
template <class T> bool CunsIn2<T>::getData(const std::string prop,
int * size,T ** farray) {
unsigned int * size,T ** farray) {
T * data=NULL;
int nbody=0;
*size=0;
......@@ -224,7 +224,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string prop,T * fvalue)
// getData
// int
template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::string prop,
int * size,int ** iarray) {
unsigned int * size,int ** iarray) {
int * data=NULL;
int nbody=0;
*size=0;
......@@ -240,7 +240,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::s
// getData
// int
template <class T> bool CunsIn2<T>::getData(const std::string prop,
int * size,int ** iarray) {
unsigned int * size,int ** iarray) {
int * data=NULL;
int nbody=0;
*size=0;
......@@ -306,14 +306,14 @@ template <class T> CunsOut2<T>::~CunsOut2()
// ----------------------------------------------------------------------------
// setData comp prop farray
template <class T> int CunsOut2<T>::setData(const std::string comp,const std::string prop,
int size,T * farray, const bool _addr) {
unsigned int size,T * farray, const bool _addr) {
int status = snapshot->setData(comp,prop,size,farray,_addr);
return status;
}
// ----------------------------------------------------------------------------
// setData prop farray
template <class T> int CunsOut2<T>::setData(const std::string prop,
int size,T * farray, const bool _addr) {
unsigned int size,T * farray, const bool _addr) {
int status = snapshot->setData(prop,size,farray,_addr);
return status;
}
......@@ -326,14 +326,14 @@ template <class T> int CunsOut2<T>::setData(const std::string prop,T fvalue) {
// ----------------------------------------------------------------------------
// setData comp prop iarray
template <class T> int CunsOut2<T>::setData(const std::string comp,const std::string prop,
int size,int * iarray, const bool _addr) {
unsigned int size,int * iarray, const bool _addr) {
int status = snapshot->setData(comp,prop,size,iarray,_addr);
return status;
}
// ----------------------------------------------------------------------------
// setData prop iarray
template <class T> int CunsOut2<T>::setData(const std::string prop,
int size,int * iarray, const bool _addr) {
unsigned int size,int * iarray, const bool _addr) {
int status = snapshot->setData(prop,size,iarray,_addr);
return status;
}
......
......@@ -58,7 +58,7 @@
namespace uns {
const std::string VERSION="1.2.0.pre-june-17th-2016"; // UNSIO version
const std::string VERSION="1.2.0.pre-November-24th-2016"; // UNSIO version
inline std::string getVersion() { return uns::VERSION; }
......@@ -150,16 +150,16 @@ enum StringData {
int nextFrame(const char * _bits);
// T
bool getData(const std::string comp,const std::string prop,
int * size,T ** farray);
unsigned int * size,T ** farray);
bool getData(const std::string prop,
int * size,T ** farray);
unsigned int * size,T ** farray);
bool getData(const std::string prop,T * fvalue);
// int
bool getData(const std::string comp,const std::string prop,
int * size,int ** iarray);
unsigned int * size,int ** iarray);
bool getData(const std::string prop,
int * size,int ** iarray);
unsigned int * size,int ** iarray);
bool getData(const std::string prop,int * ivalue);
......@@ -230,16 +230,16 @@ typedef CunsIn2<double> CunsInD;
// py wrapper
// setData FLOAT/DOUBLE
int setData(const std::string comp,const std::string prop,
int size,T * farray, const bool _addr=false);
unsigned int size,T * farray, const bool _addr=false);
int setData(const std::string prop,
int size,T * farray, const bool _addr=false);
unsigned int size,T * farray, const bool _addr=false);
int setData(const std::string prop,
T fvalue);
// setData INT
int setData(const std::string comp,const std::string prop,
int size,int * iarray, const bool _addr=false);
unsigned int size,int * iarray, const bool _addr=false);
int setData(const std::string prop,
int size,int * iarray, const bool _addr=false);
unsigned int size,int * iarray, const bool _addr=false);
int setData(const std::string prop,
int ivalue);
......
......@@ -651,7 +651,7 @@ void uns_get_interface_type_(const int * id, char * dest, int lenstring)
// return the Component Range Vector belonging to the UNS's object "index"
void getCrv(int index)
{
assert(index<(unsigned int)unsv.size());
assert((unsigned int)index<unsv.size());
crv = ((CunsIn2<float>*)unsv[index].obj)->snapshot->getSnapshotRange();
//ComponentRange::list(crv);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment