-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
%newobject ParaMEDMEM::DataArrayInt::computeAbs;
%newobject ParaMEDMEM::DataArrayInt::getIdsInRange;
%newobject ParaMEDMEM::DataArrayInt::getIdsNotInRange;
+%newobject ParaMEDMEM::DataArrayInt::getIdsStrictlyNegative;
%newobject ParaMEDMEM::DataArrayInt::Aggregate;
%newobject ParaMEDMEM::DataArrayInt::AggregateIndexes;
%newobject ParaMEDMEM::DataArrayInt::Meld;
%newobject ParaMEDMEM::DataArrayInt::buildSubstractionOptimized;
%newobject ParaMEDMEM::DataArrayInt::buildIntersection;
%newobject ParaMEDMEM::DataArrayInt::buildUnique;
+%newobject ParaMEDMEM::DataArrayInt::buildUniqueNotSorted;
%newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex;
%newobject ParaMEDMEM::DataArrayInt::buildExplicitArrByRanges;
%newobject ParaMEDMEM::DataArrayInt::buildExplicitArrOfSliceOnScaledArr;
%newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel;
%newobject ParaMEDMEM::DataArrayInt::getDifferentValues;
%newobject ParaMEDMEM::DataArrayInt::FindPermutationFromFirstToSecond;
+%newobject ParaMEDMEM::DataArrayInt::CheckAndPreparePermutation;
%newobject ParaMEDMEM::DataArrayInt::__neg__;
%newobject ParaMEDMEM::DataArrayInt::__add__;
%newobject ParaMEDMEM::DataArrayInt::__radd__;
static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step) throw(INTERP_KERNEL::Exception);
static std::string GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
static std::string GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
+ static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit) throw(INTERP_KERNEL::Exception);
void updateTime() const;
%extend
{
throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !");
int a,b;
DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !");
int a,b;
DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : the input slice contains some unknowns that can't be determined in static method !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice contains some unknowns that can't be determined in static method !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
+
+ PyObject *__getstate__() const throw(INTERP_KERNEL::Exception)
+ {
+ PyObject *ret(PyTuple_New(2));
+ std::string a0(self->getName());
+ const std::vector<std::string> &a1(self->getInfoOnComponents());
+ PyTuple_SetItem(ret,0,PyString_FromString(a0.c_str()));
+ //
+ int sz(a1.size());
+ PyObject *ret1(PyList_New(sz));
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret1,i,PyString_FromString(a1[i].c_str()));
+ PyTuple_SetItem(ret,1,ret1);
+ //
+ return ret;
+ }
+
+ void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="DataArrayDouble.__setstate__ : expected input is a tuple of size 2 with string as 1st arg and list of string as 2nd arg !";
+ if(!PyTuple_Check(inp))
+ throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid input ! Invalid overwrite of __getstate__ ?");
+ int sz(PyTuple_Size(inp));
+ if(sz!=2)
+ throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid tuple in input ! Should be of size 2 ! Invalid overwrite of __getstate__ ?");
+ PyObject *a0(PyTuple_GetItem(inp,0));
+ if(!PyString_Check(a0))
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *a1(PyTuple_GetItem(inp,1));
+ std::vector<std::string> a1cpp;
+ if(!fillStringVector(a1,a1cpp))
+ throw INTERP_KERNEL::Exception(MSG);
+ self->setName(PyString_AsString(a0));
+ self->setInfoOnComponents(a1cpp);
+ }
}
};
bool isMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception);
std::string repr() const throw(INTERP_KERNEL::Exception);
std::string reprZip() const throw(INTERP_KERNEL::Exception);
+ std::string reprNotTooLong() const throw(INTERP_KERNEL::Exception);
bool isEqual(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception);
DataArrayInt *convertToIntArr() const throw(INTERP_KERNEL::Exception);
void applyRPow(double val) throw(INTERP_KERNEL::Exception);
DataArrayDouble *negate() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *applyFunc(int nbOfComp, const std::string& func) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *applyFunc(const std::string& func) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *applyFunc2(int nbOfComp, const std::string& func) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *applyFunc(int nbOfComp, const std::string& func, bool isSafe=true) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *applyFunc(const std::string& func, bool isSafe=true) const throw(INTERP_KERNEL::Exception);
+ void applyFuncOnThis(const std::string& func, bool isSafe=true) throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *applyFunc2(int nbOfComp, const std::string& func, bool isSafe=true) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func, bool isSafe=true) const throw(INTERP_KERNEL::Exception);
void applyFuncFast32(const std::string& func) throw(INTERP_KERNEL::Exception);
void applyFuncFast64(const std::string& func) throw(INTERP_KERNEL::Exception);
DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
- return self->repr();
+ return self->reprNotTooLong();
}
double __float__() const throw(INTERP_KERNEL::Exception)
PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
+
+ // serialization
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="DataArrayDouble.__new__ : the args in input is expected to be a tuple !";
+ if(!PyTuple_Check(args))
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
+ PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
+ PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
+ //
+ PyObject *tmp0(PyTuple_New(1));
+ PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
+ PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
+ Py_DECREF(tmp0);
+ Py_DECREF(selfMeth);
+ PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
+ int sz(PyTuple_Size(args));
+
+ if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
+ {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
+ PyObject *zeNumpyRepr(0);
+ PyObject *tmp1(PyInt_FromLong(0));
+ zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed
+ Py_DECREF(tmp1);
+ PyObject *tmp3(PyTuple_New(1));
+ PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr);
+ PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
+ Py_XDECREF(tmp2);
+ Py_DECREF(tmp3);
+ }
+ Py_DECREF(initMeth);
+ return instance;
+ }
+
+ PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
+ {
+#ifdef WITH_NUMPY
+ if(!self->isAllocated())
+ throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : self is not allocated !");
+ PyObject *ret(PyTuple_New(1));
+ PyObject *ret0(PyDict_New());
+ PyObject *numpyArryObj(ParaMEDMEM_DataArrayDouble_toNumPyArray(self));
+ {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ...
+ PyObject *tmp1(PyInt_FromLong(0));
+ PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj);
+ PyTuple_SetItem(ret,0,ret0);
+ }
+ return ret;
+#else
+ throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !");
+#endif
+ }
}
};
return trueSelf;
}
+ PyObject *__len__() throw(INTERP_KERNEL::Exception)
+ {
+ return PyInt_FromLong(self->getNumberOfCompo());
+ }
+
PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
const char msg2[]="DataArrayDoubleTuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
const double *pt=self->getConstPointer();
int nbc=self->getNumberOfCompo();
- convertObjToPossibleCpp2(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
{
std::ostringstream oss;
oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
+ return 0;
}
if(singleVal>=0)
return PyFloat_FromDouble(pt[singleVal]);
std::pair<int, std::pair<int,int> > slic;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
double *pt=self->getPointer();
- convertObjToPossibleCpp2(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
switch(sw2)
{
case 1:
void fillWithZero() throw(INTERP_KERNEL::Exception);
void fillWithValue(int val) throw(INTERP_KERNEL::Exception);
void iota(int init=0) throw(INTERP_KERNEL::Exception);
+ void replaceOneValByInThis(int valToBeReplaced, int replacedBy) throw(INTERP_KERNEL::Exception);
std::string repr() const throw(INTERP_KERNEL::Exception);
std::string reprZip() const throw(INTERP_KERNEL::Exception);
+ std::string reprNotTooLong() const throw(INTERP_KERNEL::Exception);
DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const throw(INTERP_KERNEL::Exception);
DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
DataArrayInt *checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception);
bool isIdentity() const throw(INTERP_KERNEL::Exception);
+ bool isIdentity2(int sizeExpected) const throw(INTERP_KERNEL::Exception);
bool isUniform(int val) const throw(INTERP_KERNEL::Exception);
DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
void transpose() throw(INTERP_KERNEL::Exception);
void applyRPow(int val) throw(INTERP_KERNEL::Exception);
DataArrayInt *getIdsInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getIdsNotInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getIdsStrictlyNegative() const throw(INTERP_KERNEL::Exception);
bool checkAllIdsInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception);
static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2) throw(INTERP_KERNEL::Exception);
static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildUnique() const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *buildUniqueNotSorted() const throw(INTERP_KERNEL::Exception);
DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception);
void computeOffsets() throw(INTERP_KERNEL::Exception);
void computeOffsets2() throw(INTERP_KERNEL::Exception);
DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const throw(INTERP_KERNEL::Exception);
DataArrayInt *findRangeIdForEachTuple(const DataArrayInt *ranges) const throw(INTERP_KERNEL::Exception);
DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const throw(INTERP_KERNEL::Exception);
+ void sortEachPairToMakeALinkedList() throw(INTERP_KERNEL::Exception);
DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getDifferentValues() const throw(INTERP_KERNEL::Exception);
static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
- return self->repr();
+ return self->reprNotTooLong();
}
int __len__() const throw(INTERP_KERNEL::Exception)
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step);
}
+
+ PyObject *getMinMaxValues() const throw(INTERP_KERNEL::Exception)
+ {
+ int a,b;
+ self->getMinMaxValues(a,b);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyInt_FromLong(a));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(b));
+ return ret;
+ }
static PyObject *BuildOld2NewArrayFromSurjectiveFormat2(int nbOfOldTuples, PyObject *arr, PyObject *arrI) throw(INTERP_KERNEL::Exception)
{
return ret;
}
+ static DataArrayInt *CheckAndPreparePermutation(PyObject *arr) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New());
+ int szArr,sw,iTypppArr;
+ std::vector<int> stdvecTyyppArr;
+ const int *arrPtr(convertObjToPossibleCpp1_Safe(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
+ int *pt(ParaMEDMEM::DataArrayInt::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
+ ret->useArray(pt,true,ParaMEDMEM::C_DEALLOC,szArr,1);
+ return ret.retn();
+ }
+
void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception)
{
const char *msg="ParaMEDMEM::DataArrayInt::setValues : Available API are : \n-DataArrayInt.setValues([1,3,4])\n-DataArrayInt.setValues([1,3,4],3)\n-DataArrayInt.setValues([1,3,4,5],2,2)\n-DataArrayInt.New(5)\n !";
PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return pyRet;
}
+
+ PyObject *isRange() const throw(INTERP_KERNEL::Exception)
+ {
+ int a(0),b(0),c(0);
+ bool ret(self->isRange(a,b,c));
+ PyObject *pyRet=PyTuple_New(2);
+ PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0);
+ Py_XINCREF(ret0Py);
+ PyTuple_SetItem(pyRet,0,ret0Py);
+ if(ret)
+ ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
+ else
+ {
+ ret1Py=Py_None;
+ Py_XINCREF(ret1Py);
+ }
+ PyTuple_SetItem(pyRet,1,ret1Py);
+ return pyRet;
+ }
+
+ // serialization
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="DataArrayInt.__new__ : the args in input is expected to be a tuple !";
+ if(!PyTuple_Check(args))
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
+ PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
+ PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
+ //
+ PyObject *tmp0(PyTuple_New(1));
+ PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
+ PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
+ Py_DECREF(tmp0);
+ Py_DECREF(selfMeth);
+ PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
+ int sz(PyTuple_Size(args));
+
+ if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
+ {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
+ PyObject *zeNumpyRepr(0);
+ PyObject *tmp1(PyInt_FromLong(0));
+ zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed
+ Py_DECREF(tmp1);
+ PyObject *tmp3(PyTuple_New(1));
+ PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr);
+ PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
+ Py_XDECREF(tmp2);
+ Py_DECREF(tmp3);
+ }
+ Py_DECREF(initMeth);
+ return instance;
+ }
+
+ PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
+ {
+#ifdef WITH_NUMPY
+ if(!self->isAllocated())
+ throw INTERP_KERNEL::Exception("PyWrap of DataArrayInt.__getnewargs__ : self is not allocated !");
+ PyObject *ret(PyTuple_New(1));
+ PyObject *ret0(PyDict_New());
+ PyObject *numpyArryObj(ParaMEDMEM_DataArrayInt_toNumPyArray(self));
+ {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ...
+ PyObject *tmp1(PyInt_FromLong(0));
+ PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj);
+ PyTuple_SetItem(ret,0,ret0);
+ }
+ return ret;
+#else
+ throw INTERP_KERNEL::Exception("PyWrap of DataArrayInt.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !");
+#endif
+ }
}
};
Py_XINCREF(trueSelf);
return trueSelf;
}
+
+ PyObject *__len__() throw(INTERP_KERNEL::Exception)
+ {
+ return PyInt_FromLong(self->getNumberOfCompo());
+ }
PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
const int *pt=self->getConstPointer();
int nbc=self->getNumberOfCompo();
- convertObjToPossibleCpp2(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
{
std::ostringstream oss;
oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
+ return 0;
}
if(singleVal>=0)
return PyInt_FromLong(pt[singleVal]);
std::pair<int, std::pair<int,int> > slic;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
int *pt=self->getPointer();
- convertObjToPossibleCpp2(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
switch(sw2)
{
case 1:
return ParaMEDMEM_DataArrayByte_presenceOfTuple(self,obj);
}
}
+
+ DataArrayByte *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
+ {
+ self->checkAllocated();
+ const char msg[]="Unexpected situation in __setitem__ !";
+ int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
+ int sw1,sw2;
+ int i1;
+ std::vector<int> v1;
+ DataArrayInt *d1=0;
+ DataArrayIntTuple *dd1=0;
+ convertObjToPossibleCpp1(value,sw1,i1,v1,d1,dd1);
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
+ switch(sw2)
+ {
+ case 1:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 2:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 3:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 4:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 5:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 6:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 7:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 8:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 9:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 10:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 11:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 12:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 13:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 14:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 15:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 16:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ return self;
+ }
}
};
std::vector<int> stdvecTyyppArr;
std::pair<int, std::pair<int,int> > sTyyppArr;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
- convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
switch(sw)
{
case 1:
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
int nbOfCompo=self->getNumberOfComponents();
int nbOfTuples=self->getNumberOfTuples();
- convertObjToPossibleCpp2(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
int sw2;
char vc; std::string sc; std::vector<std::string> vsc; DataArrayChar *dacc=0;
convertObjToPossibleCpp6(value,sw2,vc,sc,vsc,dacc);