%include "MEDCouplingMemArray.i"
-namespace MEDCoupling
-{
- class DataArrayInt32Iterator;
+%define ARRAYDEF( ARRAY, INT )
- class DataArrayInt32 : public DataArray
- {
+// namespace MEDCoupling
+// {
+// class ARRAY ## Iterator;
+
+// class ARRAY : public DataArray -- #ifdef doesn't work inside
+// {
public:
- static DataArrayInt32 *New();
- int intValue() const;
- int getHashCode() const;
+ static ARRAY *New();
+ INT intValue() const;
+ INT getHashCode() const;
bool empty() const;
- void aggregate(const DataArrayInt32 *other);
- DataArrayInt32 *performCopyOrIncrRef(bool deepCopy) const;
- void deepCopyFrom(const DataArrayInt32& other);
+ void aggregate(const ARRAY *other);
+ ARRAY *performCopyOrIncrRef(bool deepCopy) const;
+ void deepCopyFrom(const ARRAY& other);
void reserve(std::size_t nbOfElems);
- void pushBackSilent(int val);
- int popBackSilent();
+ void pushBackSilent(INT val);
+ INT popBackSilent();
void pack() const;
- void allocIfNecessary(int nbOfTuple, int nbOfCompo);
- bool isEqual(const DataArrayInt32& other) const;
- bool isEqualWithoutConsideringStr(const DataArrayInt32& other) const;
- bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt32& other) const;
- DataArrayInt32 *buildPermutationArr(const DataArrayInt32& other) const;
- DataArrayInt32 *sumPerTuple() const;
+ void allocIfNecessary(INT nbOfTuple, INT nbOfCompo);
+ bool isEqual(const ARRAY& other) const;
+ bool isEqualWithoutConsideringStr(const ARRAY& other) const;
+ bool isEqualWithoutConsideringStrAndOrder(const ARRAY& other) const;
+ ARRAY *buildPermutationArr(const ARRAY& other) const;
+ ARRAY *sumPerTuple() const;
void sort(bool asc=true);
void reverse();
void checkMonotonic(bool increasing) const;
void checkStrictlyMonotonic(bool increasing) const;
bool isStrictlyMonotonic(bool increasing) const;
void fillWithZero();
- void fillWithValue(int val);
- void iota(int init=0);
+ void fillWithValue(INT val);
+ void iota(INT init=0);
std::string repr() const;
std::string reprZip() const;
std::string reprNotTooLong() const;
- DataArrayInt32 *invertArrayO2N2N2O(int newNbOfElem) const;
- DataArrayInt32 *invertArrayN2O2O2N(int oldNbOfElem) const;
- DataArrayInt32 *invertArrayO2N2N2OBis(int newNbOfElem) const;
-#ifndef MEDCOUPLING_USE_64BIT_IDS
- MCAuto< MapII > invertArrayN2O2O2NOptimized() const;
- MCAuto< MapII > giveN2OOptimized() const;
-#endif
- DataArrayInt32 *indicesOfSubPart(const DataArrayInt32& partOfThis) const;
- DataArrayInt32 *fromNoInterlace() const;
- DataArrayInt32 *toNoInterlace() const;
- DataArrayInt32 *selectByTupleIdSafeSlice(int bg, int end, int step) const;
- DataArrayInt32 *checkAndPreparePermutation() const;
- DataArrayInt32 *buildPermArrPerLevel() const;
- bool isIota(int sizeExpected) const;
- bool isUniform(int val) const;
- int checkUniformAndGuess() const;
+ ARRAY *invertArrayO2N2N2O(INT newNbOfElem) const;
+ ARRAY *invertArrayN2O2O2N(INT oldNbOfElem) const;
+ ARRAY *invertArrayO2N2N2OBis(INT newNbOfElem) const;
+ ARRAY *indicesOfSubPart(const ARRAY& partOfThis) const;
+ ARRAY *fromNoInterlace() const;
+ ARRAY *toNoInterlace() const;
+ ARRAY *selectByTupleIdSafeSlice(INT bg, INT end, INT step) const;
+ ARRAY *checkAndPreparePermutation() const;
+ ARRAY *buildPermArrPerLevel() const;
+ bool isIota(INT sizeExpected) const;
+ bool isUniform(INT val) const;
+ INT checkUniformAndGuess() const;
bool hasUniqueValues() const;
- DataArrayInt32 *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
+ ARRAY *subArray(INT tupleIdBg, INT tupleIdEnd=-1) const;
void transpose();
- DataArrayInt32 *changeNbOfComponents(int newNbOfComp, int dftValue) const;
- void meldWith(const DataArrayInt32 *other);
- void setPartOfValues1(const DataArrayInt32 *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
- void setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
- void setPartOfValuesAdv(const DataArrayInt32 *a, const DataArrayIdType *tuplesSelec);
- void getTuple(int tupleId, int *res) const;
- int getIJ(int tupleId, int compoId) const;
- int getIJSafe(int tupleId, int compoId) const;
- int front() const;
- int back() const;
- void setIJ(int tupleId, int compoId, int newVal);
- void setIJSilent(int tupleId, int compoId, int newVal);
- int *getPointer();
- const int *getConstPointer() const;
- DataArrayInt32Iterator *iterator();
- const int *begin() const;
- const int *end() const;
- DataArrayInt32 *findIdsEqual(int val) const;
- DataArrayInt32 *findIdsNotEqual(int val) const;
- int changeValue(int oldValue, int newValue);
- int findIdFirstEqualTuple(const std::vector<int>& tupl) const;
- int findIdFirstEqual(int value) const;
- int findIdFirstEqual(const std::vector<int>& vals) const;
- int findIdSequence(const std::vector<int>& vals) const;
- bool presenceOfTuple(const std::vector<int>& tupl) const;
- bool presenceOfValue(int value) const;
- bool presenceOfValue(const std::vector<int>& vals) const;
- int count(int value) const;
- int accumulate(int compId) const;
- int getMaxValueInArray() const;
- int getMaxAbsValueInArray() const;
- int getMinValueInArray() const;
+ ARRAY *changeNbOfComponents(INT newNbOfComp, INT dftValue) const;
+ void meldWith(const ARRAY *other);
+ void setPartOfValues1(const ARRAY *a, INT bgTuples, INT endTuples, INT stepTuples, INT bgComp, INT endComp, INT stepComp, bool strictCompoCompare=true);
+ void setPartOfValuesSimple1(INT a, INT bgTuples, INT endTuples, INT stepTuples, INT bgComp, INT endComp, INT stepComp);
+ void setPartOfValuesAdv(const ARRAY *a, const DataArrayIdType *tuplesSelec);
+ void getTuple(INT tupleId, INT *res) const;
+ INT getIJ(INT tupleId, INT compoId) const;
+ INT getIJSafe(INT tupleId, INT compoId) const;
+ INT front() const;
+ INT back() const;
+ void setIJ(INT tupleId, INT compoId, INT newVal);
+ void setIJSilent(INT tupleId, INT compoId, INT newVal);
+ INT *getPointer();
+ const INT *getConstPointer() const;
+ ARRAY ## Iterator *iterator();
+ const INT *begin() const;
+ const INT *end() const;
+ ARRAY *findIdsEqual(INT val) const;
+ ARRAY *findIdsNotEqual(INT val) const;
+ INT changeValue(INT oldValue, INT newValue);
+ INT findIdFirstEqualTuple(const std::vector<INT>& tupl) const;
+ INT findIdFirstEqual(INT value) const;
+ INT findIdFirstEqual(const std::vector<INT>& vals) const;
+ INT findIdSequence(const std::vector<INT>& vals) const;
+ bool presenceOfTuple(const std::vector<INT>& tupl) const;
+ bool presenceOfValue(INT value) const;
+ bool presenceOfValue(const std::vector<INT>& vals) const;
+ INT count(INT value) const;
+ INT accumulate(INT compId) const;
+ INT getMaxValueInArray() const;
+ INT getMaxAbsValueInArray() const;
+ INT getMinValueInArray() const;
void abs();
- DataArrayInt32 *computeAbs() const;
- void applyLin(int a, int b, int compoId);
- void applyLin(int a, int b);
- void applyInv(int numerator);
- DataArrayInt32 *negate() const;
- void applyDivideBy(int val);
- void applyModulus(int val);
- void applyRModulus(int val);
- void applyPow(int val);
- void applyRPow(int val);
- DataArrayInt32 *findIdsInRange(int vmin, int vmax) const;
- DataArrayInt32 *findIdsNotInRange(int vmin, int vmax) const;
- DataArrayInt32 *findIdsStrictlyNegative() const;
- bool checkAllIdsInRange(int vmin, int vmax) const;
- static DataArrayInt32 *Aggregate(const DataArrayInt32 *a1, const DataArrayInt32 *a2, int offsetA2);
- static DataArrayInt32 *Meld(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
- static DataArrayIdType *MakePartition(const std::vector<const DataArrayInt32 *>& groups, mcIdType newNb, std::vector< std::vector<mcIdType> >& fidsOfGroups);
- static DataArrayInt32 *BuildUnion(const std::vector<const DataArrayInt32 *>& arr);
- static DataArrayInt32 *BuildIntersection(const std::vector<const DataArrayInt32 *>& arr);
- static DataArrayInt32 *FindPermutationFromFirstToSecond(const DataArrayInt32 *ids1, const DataArrayInt32 *ids2);
- DataArrayInt32 *buildComplement(int nbOfElement) const;
- DataArrayInt32 *buildSubstraction(const DataArrayInt32 *other) const;
- DataArrayInt32 *buildSubstractionOptimized(const DataArrayInt32 *other) const;
- DataArrayInt32 *buildUnion(const DataArrayInt32 *other) const;
- DataArrayInt32 *buildIntersection(const DataArrayInt32 *other) const;
- DataArrayInt32 *buildUnique() const;
- DataArrayInt32 *buildUniqueNotSorted() const;
- DataArrayInt32 *deltaShiftIndex() const;
+ ARRAY *computeAbs() const;
+ void applyLin(INT a, INT b, INT compoId);
+ void applyLin(INT a, INT b);
+ void applyInv(INT numerator);
+ ARRAY *negate() const;
+ void applyDivideBy(INT val);
+ void applyModulus(INT val);
+ void applyRModulus(INT val);
+ void applyPow(INT val);
+ void applyRPow(INT val);
+ ARRAY *findIdsInRange(INT vmin, INT vmax) const;
+ ARRAY *findIdsNotInRange(INT vmin, INT vmax) const;
+ ARRAY *findIdsStrictlyNegative() const;
+ bool checkAllIdsInRange(INT vmin, INT vmax) const;
+ static ARRAY *Aggregate(const ARRAY *a1, const ARRAY *a2, INT offsetA2);
+ static ARRAY *Meld(const ARRAY *a1, const ARRAY *a2);
+ static DataArrayIdType *MakePartition(const std::vector<const ARRAY *>& groups, mcIdType newNb, std::vector< std::vector<mcIdType> >& fidsOfGroups);
+ static ARRAY *BuildUnion(const std::vector<const ARRAY *>& arr);
+ static ARRAY *BuildIntersection(const std::vector<const ARRAY *>& arr);
+ static ARRAY *FindPermutationFromFirstToSecond(const ARRAY *ids1, const ARRAY *ids2);
+ ARRAY *buildComplement(INT nbOfElement) const;
+ ARRAY *buildSubstraction(const ARRAY *other) const;
+ ARRAY *buildSubstractionOptimized(const ARRAY *other) const;
+ ARRAY *buildUnion(const ARRAY *other) const;
+ ARRAY *buildIntersection(const ARRAY *other) const;
+ ARRAY *buildUnique() const;
+ ARRAY *buildUniqueNotSorted() const;
+ ARRAY *deltaShiftIndex() const;
void computeOffsets();
void computeOffsetsFull();
- DataArrayInt32 *buildExplicitArrByRanges(const DataArrayInt32 *offsets) const;
- DataArrayInt32 *findRangeIdForEachTuple(const DataArrayInt32 *ranges) const;
- DataArrayInt32 *findIdInRangeForEachTuple(const DataArrayInt32 *ranges) const;
+ ARRAY *buildExplicitArrByRanges(const ARRAY *offsets) const;
+ ARRAY *findRangeIdForEachTuple(const ARRAY *ranges) const;
+ ARRAY *findIdInRangeForEachTuple(const ARRAY *ranges) const;
void sortEachPairToMakeALinkedList();
- DataArrayInt32 *duplicateEachTupleNTimes(int nbTimes) const;
- DataArrayInt32 *getDifferentValues() const;
- static DataArrayInt32 *Add(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
- void addEqual(const DataArrayInt32 *other);
- static DataArrayInt32 *Substract(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
- void substractEqual(const DataArrayInt32 *other);
- static DataArrayInt32 *Multiply(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
- void multiplyEqual(const DataArrayInt32 *other);
- static DataArrayInt32 *Divide(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
- void divideEqual(const DataArrayInt32 *other);
- static DataArrayInt32 *Modulus(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
- void modulusEqual(const DataArrayInt32 *other);
- static DataArrayInt32 *Pow(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
- void powEqual(const DataArrayInt32 *other);
- MCAuto<DataArrayInt32> fromLinkedListOfPairToList() const;
- MCAuto<DataArrayIdType> findIdsGreaterOrEqualTo(int val) const;
- MCAuto<DataArrayIdType> findIdsGreaterThan(int val) const;
- MCAuto<DataArrayIdType> findIdsLowerOrEqualTo(int val) const;
- MCAuto<DataArrayIdType> findIdsLowerThan(int val) const;
- MCAuto<DataArrayInt32> selectPartDef(const PartDefinition* pd) const;
+ ARRAY *duplicateEachTupleNTimes(INT nbTimes) const;
+ ARRAY *getDifferentValues() const;
+ static ARRAY *Add(const ARRAY *a1, const ARRAY *a2);
+ void addEqual(const ARRAY *other);
+ static ARRAY *Substract(const ARRAY *a1, const ARRAY *a2);
+ void substractEqual(const ARRAY *other);
+ static ARRAY *Multiply(const ARRAY *a1, const ARRAY *a2);
+ void multiplyEqual(const ARRAY *other);
+ static ARRAY *Divide(const ARRAY *a1, const ARRAY *a2);
+ void divideEqual(const ARRAY *other);
+ static ARRAY *Modulus(const ARRAY *a1, const ARRAY *a2);
+ void modulusEqual(const ARRAY *other);
+ static ARRAY *Pow(const ARRAY *a1, const ARRAY *a2);
+ void powEqual(const ARRAY *other);
+ MCAuto<ARRAY> fromLinkedListOfPairToList() const;
+ MCAuto<DataArrayIdType> findIdsGreaterOrEqualTo(INT val) const;
+ MCAuto<DataArrayIdType> findIdsGreaterThan(INT val) const;
+ MCAuto<DataArrayIdType> findIdsLowerOrEqualTo(INT val) const;
+ MCAuto<DataArrayIdType> findIdsLowerThan(INT val) const;
+ MCAuto<ARRAY> selectPartDef(const PartDefinition* pd) const;
MCAuto<DataArrayDouble> convertToDblArr() const;
MCAuto<DataArrayFloat> convertToFloatArr() const;
public:
- static DataArrayInt32 *Range(int begin, int end, int step);
+ static ARRAY *Range(INT begin, INT end, INT step);
%extend
{
- DataArrayInt32()
+ ARRAY()
{
- return DataArrayInt32::New();
+ return ARRAY::New();
}
- static DataArrayInt32 *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
+ static ARRAY *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
{
- const char *msgBase="MEDCoupling::DataArrayInt32::New : Available API are : \n-DataArrayInt32.New()\n-DataArrayInt32.New([1,3,4])\n-DataArrayInt32.New([1,3,4],3)\n-DataArrayInt32.New([1,3,4,5],2,2)\n-DataArrayInt32.New([1,3,4,5,7,8],3,2)\n-DataArrayInt32.New([(1,3),(4,5),(7,8)])\n-DataArrayInt32.New(5)\n-DataArrayInt32.New(5,2)";
+ const char *msgBase="MEDCoupling::ARRAY::New : Available API are : \n-ARRAY.New()\n-ARRAY.New([1,3,4])\n-ARRAY.New([1,3,4],3)\n-ARRAY.New([1,3,4,5],2,2)\n-ARRAY.New([1,3,4,5,7,8],3,2)\n-ARRAY.New([(1,3),(4,5),(7,8)])\n-ARRAY.New(5)\n-ARRAY.New(5,2)";
std::string msg(msgBase);
-#ifdef WITH_NUMPY
- msg+="\n-DataArrayInt32.New(numpy array with dtype=int32)";
-#endif
+ if ( MEDCouplingHasNumPyBindings() )
+ msg+="\n-ARRAY.New(numpy array with dtype=int32)";
+
msg+=" !";
if(PyList_Check(elt0) || PyTuple_Check(elt0))
{
{
mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
if(nbOfTuples1<0)
- throw INTERP_KERNEL::Exception("DataArrayInt32::New : should be a positive set of allocated memory !");
+ throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
if(nbOfComp)
{
if(PyInt_Check(nbOfComp))
- {//DataArrayInt32.New([1,3,4,5],2,2)
+ {//ARRAY.New([1,3,4,5],2,2)
mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp);
if(nbOfCompo<0)
- throw INTERP_KERNEL::Exception("DataArrayInt32::New : should be a positive number of components !");
- MCAuto<DataArrayInt32> ret=DataArrayInt32::New();
- std::vector<int> tmp=fillArrayWithPyListInt2<int>(elt0,nbOfTuples1,nbOfCompo);
+ throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
+ MCAuto<ARRAY> ret=ARRAY::New();
+ std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,nbOfCompo);
ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
return ret.retn();
}
throw INTERP_KERNEL::Exception(msg.c_str());
}
else
- {//DataArrayInt32.New([1,3,4],3)
- MCAuto<DataArrayInt32> ret=DataArrayInt32::New();
+ {//ARRAY.New([1,3,4],3)
+ MCAuto<ARRAY> ret=ARRAY::New();
mcIdType tmpp1=-1;
- std::vector<int> tmp=fillArrayWithPyListInt2<int>(elt0,nbOfTuples1,tmpp1);
+ std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,tmpp1);
ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
return ret.retn();
}
throw INTERP_KERNEL::Exception(msg.c_str());
}
else
- {// DataArrayInt32.New([1,3,4])
- MCAuto<DataArrayInt32> ret=DataArrayInt32::New();
+ {// ARRAY.New([1,3,4])
+ MCAuto<ARRAY> ret=ARRAY::New();
mcIdType tmpp1=-1,tmpp2=-1;
- std::vector<int> tmp=fillArrayWithPyListInt2<int>(elt0,tmpp1,tmpp2);
+ std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,tmpp1,tmpp2);
ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
return ret.retn();
}
}
else if(PyInt_Check(elt0))
{
- int nbOfTuples1=PyInt_AS_LONG(elt0);
+ INT nbOfTuples1=PyInt_AS_LONG(elt0);
if(nbOfTuples1<0)
- throw INTERP_KERNEL::Exception("DataArrayInt32::New : should be a positive set of allocated memory !");
+ throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
if(nbOfTuples)
{
if(!nbOfComp)
{
if(PyInt_Check(nbOfTuples))
- {//DataArrayInt32.New(5,2)
- int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
+ {//ARRAY.New(5,2)
+ INT nbOfCompo=PyInt_AS_LONG(nbOfTuples);
if(nbOfCompo<0)
- throw INTERP_KERNEL::Exception("DataArrayInt32::New : should be a positive number of components !");
- MCAuto<DataArrayInt32> ret=DataArrayInt32::New();
+ throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
+ MCAuto<ARRAY> ret=ARRAY::New();
ret->alloc(nbOfTuples1,nbOfCompo);
return ret.retn();
}
throw INTERP_KERNEL::Exception(msg.c_str());
}
else
- {//DataArrayInt32.New(5)
- MCAuto<DataArrayInt32> ret=DataArrayInt32::New();
+ {//ARRAY.New(5)
+ MCAuto<ARRAY> ret=ARRAY::New();
ret->alloc(nbOfTuples1,1);
return ret.retn();
}
}
-#ifdef WITH_NUMPY
- else if(PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
- {//DataArrayInt32.New(numpyArray)
- return BuildNewInstance<DataArrayInt32,int>(elt0,NPY_INT32,&PyCallBackDataArrayInt_RefType,"INT32");
+ else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
+ {//ARRAY.New(numpyArray)
+ return BuildNewInstance<ARRAY,INT>(elt0,NPY_INT32,&PyCallBackDataArrayInt_RefType,"INT32");
}
-#endif
else
throw INTERP_KERNEL::Exception(msg.c_str());
throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
}
- DataArrayInt32(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
+ ARRAY(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
{
- return MEDCoupling_DataArrayInt32_New__SWIG_1(elt0,nbOfTuples,nbOfComp);
+ return MEDCoupling_ ## ARRAY ## _New__SWIG_1(elt0,nbOfTuples,nbOfComp);
}
std::string __str__() const
return self->reprNotTooLong();
}
- int __len__() const
+ INT __len__() const
{
if(self->isAllocated())
{
}
else
{
- throw INTERP_KERNEL::Exception("DataArrayInt32::__len__ : Instance is NOT allocated !");
+ throw INTERP_KERNEL::Exception("ARRAY::__len__ : Instance is NOT allocated !");
}
}
- int __int__() const
+ INT __int__() const
{
return self->intValue();
}
- DataArrayInt32Iterator *__iter__()
+ ARRAY ## Iterator *__iter__()
{
return self->iterator();
}
PyObject *accumulate() const
{
mcIdType sz=self->getNumberOfComponents();
- INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
- self->accumulate((int *)tmp);
- return convertIntArrToPyList((const int *)tmp,sz);
+ INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
+ self->accumulate((INT *)tmp);
+ return convertIntArrToPyList((const INT *)tmp,sz);
}
- DataArrayInt32 *accumulatePerChunck(PyObject *indexArr) const
+ ARRAY *accumulatePerChunck(PyObject *indexArr) const
{
mcIdType sw,sz,val;
std::vector<mcIdType> val2;
DataArrayIdType *findIdsEqualTuple(PyObject *inputTuple) const
{
mcIdType sw,sz;
- int val;
- std::vector<int> val2;
- const int *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
+ INT val;
+ std::vector<INT> val2;
+ const INT *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
return self->findIdsEqualTuple(bg,bg+sz);
}
DataArrayIdType *findIdForEach(PyObject *vals) const
{
mcIdType sw,sz;
- int val;
- std::vector<int> val2;
- const int *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
+ INT val;
+ std::vector<INT> val2;
+ const INT *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
MCAuto<DataArrayIdType> ret(self->findIdForEach(bg,bg+sz));
return ret.retn();
}
return ret;
}
- DataArrayInt32 *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
+ ARRAY *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
{
if(!PySlice_Check(slic))
- throw INTERP_KERNEL::Exception("DataArrayInt32::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
+ throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
- GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArrayInt32::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArrayInt32::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
+ GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
+ if(strt==std::numeric_limits<INT>::max() || stp==std::numeric_limits<INT>::max())
+ throw INTERP_KERNEL::Exception("ARRAY::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
{
- int a,b;
+ INT a,b;
self->getMinMaxValues(a,b);
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,PyInt_FromLong(a));
{
mcIdType newNbOfTuples=-1;
mcIdType szArr,szArrI,sw,iTypppArrI;
- int iTypppArr;
- std::vector<int> stdvecTyyppArr;
+ INT iTypppArr;
+ std::vector<INT> stdvecTyyppArr;
std::vector<mcIdType> stdvecTyyppArrI;
- const int *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
+ const INT *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
const mcIdType *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI);
- DataArrayIdType *ret0=MEDCoupling::DataArrayInt32::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
+ DataArrayIdType *ret0=MEDCoupling::ARRAY::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples));
{
MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
mcIdType szArr,sw;
- int iTypppArr;
- std::vector<int> stdvecTyyppArr;
- const int *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
- mcIdType *pt(MEDCoupling::DataArrayInt32::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
+ INT iTypppArr;
+ std::vector<INT> stdvecTyyppArr;
+ const INT *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
+ mcIdType *pt(MEDCoupling::ARRAY::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1);
return ret.retn();
}
void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
{
- const char *msg="MEDCoupling::DataArrayInt32::setValues : Available API are : \n-DataArrayInt32.setValues([1,3,4])\n-DataArrayInt32.setValues([1,3,4],3)\n-DataArrayInt32.setValues([1,3,4,5],2,2)\n-DataArrayInt32.New(5)\n !";
+ const char *msg="MEDCoupling::ARRAY::setValues : Available API are : \n-ARRAY.setValues([1,3,4])\n-ARRAY.setValues([1,3,4],3)\n-ARRAY.setValues([1,3,4,5],2,2)\n-ARRAY.New(5)\n !";
if(PyList_Check(li) || PyTuple_Check(li))
{
if(nbOfTuples && nbOfTuples != Py_None)
{
mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
if(nbOfTuples1<0)
- throw INTERP_KERNEL::Exception("DataArrayInt32::setValue : should be a positive set of allocated memory !");
+ throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !");
if(nbOfComp && nbOfComp != Py_None)
{
if(PyInt_Check(nbOfComp))
- {//DataArrayInt32.setValues([1,3,4,5],2,2)
+ {//ARRAY.setValues([1,3,4,5],2,2)
mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp);
if(nbOfCompo<0)
- throw INTERP_KERNEL::Exception("DataArrayInt32::setValue : should be a positive number of components !");
- std::vector<int> tmp=fillArrayWithPyListInt2<int>(li,nbOfTuples1,nbOfCompo);
+ throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !");
+ std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,nbOfCompo);
self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
}
else
throw INTERP_KERNEL::Exception(msg);
}
else
- {//DataArrayInt32.setValues([1,3,4],3)
+ {//ARRAY.setValues([1,3,4],3)
mcIdType tmpp1=-1;
- std::vector<int> tmp=fillArrayWithPyListInt2<int>(li,nbOfTuples1,tmpp1);
+ std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,tmpp1);
self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
}
}
throw INTERP_KERNEL::Exception(msg);
}
else
- {// DataArrayInt32.setValues([1,3,4])
+ {// ARRAY.setValues([1,3,4])
mcIdType tmpp1=-1,tmpp2=-1;
- std::vector<int> tmp=fillArrayWithPyListInt2<int>(li,tmpp1,tmpp2);
+ std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,tmpp1,tmpp2);
self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
}
}
PyObject *getValues() const
{
- const int *vals=self->getConstPointer();
+ const INT *vals=self->getConstPointer();
return convertIntArrToPyList(vals,self->getNbOfElems());
}
-#ifdef WITH_NUMPY
- PyObject *toNumPyArray() // not const. It is not a bug !
- {
- return ToNumPyArray<DataArrayInt32,int>(self,NPY_INT32,"DataArrayInt32");
- }
-#endif
-
- PyObject *isEqualIfNotWhy(const DataArrayInt32& other) const
+ PyObject *isEqualIfNotWhy(const ARRAY& other) const
{
std::string ret1;
bool ret0=self->isEqualIfNotWhy(other,ret1);
PyObject *getValuesAsTuple() const
{
- const int *vals=self->getConstPointer();
+ const INT *vals=self->getConstPointer();
mcIdType nbOfComp=self->getNumberOfComponents();
mcIdType nbOfTuples=self->getNumberOfTuples();
return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
static PyObject *MakePartition(PyObject *gps, mcIdType newNb)
{
- std::vector<const DataArrayInt32 *> groups;
+ std::vector<const ARRAY *> groups;
std::vector< std::vector<mcIdType> > fidsOfGroups;
- convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt32 *>(gps,SWIGTITraits<mcIdType>::TI,"DataArrayInt32",groups);
- DataArrayIdType *ret0=MEDCoupling::DataArrayInt32::MakePartition(groups,newNb,fidsOfGroups);
+ convertFromPyObjVectorOfObj<const MEDCoupling::ARRAY *>(gps,SWIGTITraits<mcIdType>::TI,"ARRAY",groups);
+ DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups);
PyObject *ret = PyList_New(2);
PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
mcIdType sz=fidsOfGroups.size();
return ret;
}
-#ifndef MEDCOUPLING_USE_64BIT_IDS
- void transformWithIndArr(PyObject *li)
- {
- void *da=0;
- int res1(SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 ));
- if (!SWIG_IsOK(res1))
- {
- int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
- if(SWIG_IsOK(res2))
- {
- MapII *m=reinterpret_cast<MapII *>(da);
- self->transformWithIndArr(*m);
- }
- else
- {
- mcIdType size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2<int>(li,&size);
- self->transformWithIndArr(tmp,tmp+size);
- }
- }
- else
- {
- DataArrayInt32 *da2=reinterpret_cast< DataArrayInt32 * >(da);
- self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
- }
- }
-#endif
DataArrayIdType *findIdsEqualList(PyObject *obj)
{
mcIdType sw;
- int singleVal;
- std::vector<int> multiVal;
+ INT singleVal;
+ std::vector<INT> multiVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
- DataArrayInt32 *daIntTyypp=0;
+ ARRAY *daIntTyypp=0;
convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 4:
return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
default:
- throw INTERP_KERNEL::Exception("DataArrayInt32::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt32 !");
+ throw INTERP_KERNEL::Exception("ARRAY::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
}
}
DataArrayIdType *findIdsNotEqualList(PyObject *obj)
{
mcIdType sw;
- int singleVal;
- std::vector<int> multiVal;
+ INT singleVal;
+ std::vector<INT> multiVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
- DataArrayInt32 *daIntTyypp=0;
+ ARRAY *daIntTyypp=0;
convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 4:
return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
default:
- throw INTERP_KERNEL::Exception("DataArrayInt32::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt32 !");
+ throw INTERP_KERNEL::Exception("ARRAY::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
}
}
PyObject *splitByValueRange(PyObject *li) const
{
- DataArrayInt32 *ret0=0,*ret1=0,*ret2=0;
+ ARRAY *ret0=0,*ret1=0,*ret2=0;
void *da=0;
int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
if (!SWIG_IsOK(res1))
{
mcIdType size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2<int>(li,&size);
- self->splitByValueRange(tmp,(int *)tmp+size,ret0,ret1,ret2);
+ INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
+ self->splitByValueRange(tmp,(INT *)tmp+size,ret0,ret1,ret2);
}
else
{
- DataArrayInt32 *da2=reinterpret_cast< DataArrayInt32 * >(da);
+ ARRAY *da2=reinterpret_cast< ARRAY * >(da);
if(!da2)
- throw INTERP_KERNEL::Exception("Not null DataArrayInt32 instance expected !");
+ throw INTERP_KERNEL::Exception("Not null ARRAY instance expected !");
da2->checkAllocated();
self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2);
}
if (!SWIG_IsOK(res1))
{
mcIdType size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2<int>(li,&size);
+ INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
return self->transformWithIndArrR(tmp,tmp+size);
}
else
{
- DataArrayInt32 *da2=reinterpret_cast< DataArrayInt32 * >(da);
+ ARRAY *da2=reinterpret_cast< ARRAY * >(da);
return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
}
}
- DataArrayInt32 *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple)
+ ARRAY *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple)
{
void *da=0;
int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
}
}
- DataArrayInt32 *renumber(PyObject *li)
+ ARRAY *renumber(PyObject *li)
{
void *da=0;
int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
}
}
- DataArrayInt32 *renumberR(PyObject *li)
+ ARRAY *renumberR(PyObject *li)
{
void *da=0;
int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 );
}
}
- void setSelectedComponents(const DataArrayInt32 *a, PyObject *li)
+ void setSelectedComponents(const ARRAY *a, PyObject *li)
{
std::vector<std::size_t> tmp;
convertPyToNewIntArr3(li,tmp);
PyObject *explodeComponents() const
{
- std::vector< MCAuto<DataArrayInt32> > retCpp(self->explodeComponents());
+ std::vector< MCAuto<ARRAY> > retCpp(self->explodeComponents());
std::size_t sz(retCpp.size());
PyObject *res(PyList_New(sz));
for(std::size_t i=0;i<sz;i++)
PyObject *getTuple(mcIdType tupleId)
{
mcIdType sz=self->getNumberOfComponents();
- INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
+ INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
self->getTuple(tupleId,tmp);
- return convertIntArrToPyList((const int*)tmp,sz);
+ return convertIntArrToPyList((const INT*)tmp,sz);
}
- PyObject *changeSurjectiveFormat(int targetNb) const
+ PyObject *changeSurjectiveFormat(INT targetNb) const
{
DataArrayIdType *arr=0;
DataArrayIdType *arrI=0;
return res;
}
- static DataArrayInt32 *Meld(PyObject *li)
+ static ARRAY *Meld(PyObject *li)
{
- std::vector<const DataArrayInt32 *> tmp;
- convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt32 *>(li,SWIGTITraits<mcIdType>::TI,"DataArrayInt32",tmp);
- return DataArrayInt32::Meld(tmp);
+ std::vector<const ARRAY *> tmp;
+ convertFromPyObjVectorOfObj<const MEDCoupling::ARRAY *>(li,SWIGTITraits<mcIdType>::TI,"ARRAY",tmp);
+ return ARRAY::Meld(tmp);
}
- static DataArrayInt32 *Aggregate(PyObject *li)
+ static ARRAY *Aggregate(PyObject *li)
{
- std::vector<const DataArrayInt32 *> tmp;
- convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt32 *>(li,SWIGTITraits<mcIdType>::TI,"DataArrayInt32",tmp);
- return DataArrayInt32::Aggregate(tmp);
+ std::vector<const ARRAY *> tmp;
+ convertFromPyObjVectorOfObj<const MEDCoupling::ARRAY *>(li,SWIGTITraits<mcIdType>::TI,"ARRAY",tmp);
+ return ARRAY::Aggregate(tmp);
}
- static DataArrayInt32 *AggregateIndexes(PyObject *li)
+ static ARRAY *AggregateIndexes(PyObject *li)
{
- std::vector<const DataArrayInt32 *> tmp;
- convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt32 *>(li,SWIGTITraits<mcIdType>::TI,"DataArrayInt32",tmp);
- return DataArrayInt32::AggregateIndexes(tmp);
+ std::vector<const ARRAY *> tmp;
+ convertFromPyObjVectorOfObj<const MEDCoupling::ARRAY *>(li,SWIGTITraits<mcIdType>::TI,"ARRAY",tmp);
+ return ARRAY::AggregateIndexes(tmp);
}
- static DataArrayInt32 *BuildUnion(PyObject *li)
+ static ARRAY *BuildUnion(PyObject *li)
{
- std::vector<const DataArrayInt32 *> tmp;
- convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt32 *>(li,SWIGTITraits<mcIdType>::TI,"DataArrayInt32",tmp);
- return DataArrayInt32::BuildUnion(tmp);
+ std::vector<const ARRAY *> tmp;
+ convertFromPyObjVectorOfObj<const MEDCoupling::ARRAY *>(li,SWIGTITraits<mcIdType>::TI,"ARRAY",tmp);
+ return ARRAY::BuildUnion(tmp);
}
- static DataArrayInt32 *BuildIntersection(PyObject *li)
+ static ARRAY *BuildIntersection(PyObject *li)
{
- std::vector<const DataArrayInt32 *> tmp;
- convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt32 *>(li,SWIGTITraits<mcIdType>::TI,"DataArrayInt32",tmp);
- return DataArrayInt32::BuildIntersection(tmp);
+ std::vector<const ARRAY *> tmp;
+ convertFromPyObjVectorOfObj<const MEDCoupling::ARRAY *>(li,SWIGTITraits<mcIdType>::TI,"ARRAY",tmp);
+ return ARRAY::BuildIntersection(tmp);
}
PyObject *getMaxValue() const
{
mcIdType tmp;
- int r1=self->getMaxValue(tmp);
+ INT r1=self->getMaxValue(tmp);
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
PyObject *getMaxAbsValue(std::size_t& tupleId) const
{
std::size_t tmp;
- int r1=self->getMaxAbsValue(tmp);
+ INT r1=self->getMaxAbsValue(tmp);
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
PyObject *getMinValue() const
{
mcIdType tmp;
- int r1=self->getMinValue(tmp);
+ INT r1=self->getMinValue(tmp);
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
{
if(PyInt_Check(obj))
{
- int val=(int)PyInt_AS_LONG(obj);
+ INT val=(INT)PyInt_AS_LONG(obj);
return self->findIdFirstEqual(val);
}
else
- throw INTERP_KERNEL::Exception("DataArrayInt32::index : 'this' contains one component and trying to find an element which is not an integer !");
+ throw INTERP_KERNEL::Exception("ARRAY::index : 'this' contains one component and trying to find an element which is not an integer !");
}
default:
{
- std::vector<int> arr;
+ std::vector<INT> arr;
convertPyToNewIntArr3(obj,arr);
return self->findIdFirstEqualTuple(arr);
}
{
if(PyInt_Check(obj))
{
- int val=(int)PyInt_AS_LONG(obj);
+ INT val=(INT)PyInt_AS_LONG(obj);
return self->presenceOfValue(val);
}
else
- throw INTERP_KERNEL::Exception("DataArrayInt32::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
+ throw INTERP_KERNEL::Exception("ARRAY::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
}
default:
{
- std::vector<int> arr;
+ std::vector<INT> arr;
convertPyToNewIntArr3(obj,arr);
return self->presenceOfTuple(arr);
}
PyObject *__getitem__(PyObject *obj)
{
- const char msg[]="Unexpected situation in DataArrayInt32::__getitem__ !";
- const char msg2[]="DataArrayInt32::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
+ const char msg[]="Unexpected situation in ARRAY::__getitem__ !";
+ const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
self->checkAllocated();
mcIdType nbOfTuples=self->getNumberOfTuples();
mcIdType nbOfComponents=self->getNumberOfComponents();
DataArrayIdType *dt1=0,*dc1=0;
mcIdType sw;
convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
- MCAuto<DataArrayInt32> ret;
+ MCAuto<ARRAY> ret;
switch(sw)
{
case 1:
ret=self->selectByTupleIdSafe(&it1,&it1+1);
mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
std::vector<std::size_t> v2(nbOfComp);
- for(int i=0;i<nbOfComp;i++)
+ for(INT i=0;i<nbOfComp;i++)
v2[i]=pc1.first+i*pc1.second.second;
return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 );
}
ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
std::vector<std::size_t> v2(nbOfComp);
- for(int i=0;i<nbOfComp;i++)
+ for(INT i=0;i<nbOfComp;i++)
v2[i]=pc1.first+i*pc1.second.second;
return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 );
}
ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
std::vector<std::size_t> v2(nbOfComp);
- for(int i=0;i<nbOfComp;i++)
+ for(INT i=0;i<nbOfComp;i++)
v2[i]=pc1.first+i*pc1.second.second;
return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 );
}
}
}
- DataArrayInt32 *__setitem__(PyObject *obj, PyObject *value)
+ ARRAY *__setitem__(PyObject *obj, PyObject *value)
{
self->checkAllocated();
const char msg[]="Unexpected situation in __setitem__ !";
mcIdType nbOfTuples=self->getNumberOfTuples();
mcIdType nbOfComponents=self->getNumberOfComponents();
mcIdType sw1,sw2;
- int i1;
- std::vector<int> v1;
- DataArrayInt32 *d1=0;
- DataArrayInt32Tuple *dd1=0;
+ INT i1;
+ std::vector<INT> v1;
+ ARRAY *d1=0;
+ ARRAY ## Tuple *dd1=0;
convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
mcIdType it1,ic1;
std::vector<mcIdType> vt1,vc1;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
DataArrayIdType *dt1=0,*dc1=0;
convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
- MCAuto<DataArrayInt32> tmp;
+ MCAuto<ARRAY> tmp;
switch(sw2)
{
case 1:
self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
return self;
self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
return self;
self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
return self;
self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
return self;
self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
return self;
self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
return self;
self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
return self;
self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
return self;
self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
return self;
self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
return self;
self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
return self;
self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
return self;
self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
return self;
self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
return self;
self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
return self;
self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
return self;
case 2:
- tmp=DataArrayInt32::New();
+ tmp=ARRAY::New();
tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
return self;
return self;
}
- DataArrayInt32 *__neg__() const
+ ARRAY *__neg__() const
{
return self->negate();
}
- DataArrayInt32 *__add__(PyObject *obj)
+ ARRAY *__add__(PyObject *obj)
{
const char msg[]="Unexpected situation in __add__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayIntTuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyLin(1,val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Add(self,aaaa);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Add(self,aaaa);
}
case 3:
{
- return DataArrayInt32::Add(self,a);
+ return ARRAY::Add(self,a);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Add(self,aaaa);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Add(self,aaaa);
}
default:
throw INTERP_KERNEL::Exception(msg);
}
}
- DataArrayInt32 *__radd__(PyObject *obj)
+ ARRAY *__radd__(PyObject *obj)
{
const char msg[]="Unexpected situation in __radd__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayIntTuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyLin(1,val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Add(self,aaaa);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Add(self,aaaa);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Add(self,aaaa);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Add(self,aaaa);
}
default:
throw INTERP_KERNEL::Exception(msg);
PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
{
const char msg[]="Unexpected situation in __iadd__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
}
case 2:
{
- MCAuto<DataArrayInt32> bb=DataArrayInt32::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
self->addEqual(bb);
Py_XINCREF(trueSelf);
return trueSelf;
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
self->addEqual(aaaa);
Py_XINCREF(trueSelf);
return trueSelf;
}
}
- DataArrayInt32 *__sub__(PyObject *obj)
+ ARRAY *__sub__(PyObject *obj)
{
const char msg[]="Unexpected situation in __sub__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyLin(1,-val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Substract(self,aaaa);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Substract(self,aaaa);
}
case 3:
{
- return DataArrayInt32::Substract(self,a);
+ return ARRAY::Substract(self,a);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Substract(self,aaaa);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Substract(self,aaaa);
}
default:
throw INTERP_KERNEL::Exception(msg);
}
}
- DataArrayInt32 *__rsub__(PyObject *obj)
+ ARRAY *__rsub__(PyObject *obj)
{
const char msg[]="Unexpected situation in __rsub__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyLin(-1,val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Substract(aaaa,self);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Substract(aaaa,self);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Substract(aaaa,self);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Substract(aaaa,self);
}
default:
throw INTERP_KERNEL::Exception(msg);
PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
{
const char msg[]="Unexpected situation in __isub__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
}
case 2:
{
- MCAuto<DataArrayInt32> bb=DataArrayInt32::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
self->substractEqual(bb);
Py_XINCREF(trueSelf);
return trueSelf;
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
self->substractEqual(aaaa);
Py_XINCREF(trueSelf);
return trueSelf;
}
}
- DataArrayInt32 *__mul__(PyObject *obj)
+ ARRAY *__mul__(PyObject *obj)
{
const char msg[]="Unexpected situation in __mul__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyLin(val,0);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Multiply(self,aaaa);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Multiply(self,aaaa);
}
case 3:
{
- return DataArrayInt32::Multiply(self,a);
+ return ARRAY::Multiply(self,a);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Multiply(self,aaaa);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Multiply(self,aaaa);
}
default:
throw INTERP_KERNEL::Exception(msg);
}
}
- DataArrayInt32 *__rmul__(PyObject *obj)
+ ARRAY *__rmul__(PyObject *obj)
{
const char msg[]="Unexpected situation in __rmul__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyLin(val,0);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Multiply(self,aaaa);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Multiply(self,aaaa);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Multiply(self,aaaa);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Multiply(self,aaaa);
}
default:
throw INTERP_KERNEL::Exception(msg);
PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
{
const char msg[]="Unexpected situation in __imul__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
}
case 2:
{
- MCAuto<DataArrayInt32> bb=DataArrayInt32::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
self->multiplyEqual(bb);
Py_XINCREF(trueSelf);
return trueSelf;
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
self->multiplyEqual(aaaa);
Py_XINCREF(trueSelf);
return trueSelf;
}
}
- DataArrayInt32 *__div__(PyObject *obj)
+ ARRAY *__div__(PyObject *obj)
{
const char msg[]="Unexpected situation in __div__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyDivideBy(val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Divide(self,aaaa);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Divide(self,aaaa);
}
case 3:
{
- return DataArrayInt32::Divide(self,a);
+ return ARRAY::Divide(self,a);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Divide(self,aaaa);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Divide(self,aaaa);
}
default:
throw INTERP_KERNEL::Exception(msg);
}
}
- DataArrayInt32 *__rdiv__(PyObject *obj)
+ ARRAY *__rdiv__(PyObject *obj)
{
const char msg[]="Unexpected situation in __rdiv__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyInv(val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Divide(aaaa,self);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Divide(aaaa,self);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Divide(aaaa,self);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Divide(aaaa,self);
}
default:
throw INTERP_KERNEL::Exception(msg);
PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
{
const char msg[]="Unexpected situation in __idiv__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
}
case 2:
{
- MCAuto<DataArrayInt32> bb=DataArrayInt32::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
self->divideEqual(bb);
Py_XINCREF(trueSelf);
return trueSelf;
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
self->divideEqual(aaaa);
Py_XINCREF(trueSelf);
return trueSelf;
}
}
- DataArrayInt32 *__mod__(PyObject *obj)
+ ARRAY *__mod__(PyObject *obj)
{
const char msg[]="Unexpected situation in __mod__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyModulus(val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Modulus(self,aaaa);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Modulus(self,aaaa);
}
case 3:
{
- return DataArrayInt32::Modulus(self,a);
+ return ARRAY::Modulus(self,a);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Modulus(self,aaaa);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Modulus(self,aaaa);
}
default:
throw INTERP_KERNEL::Exception(msg);
}
}
- DataArrayInt32 *__rmod__(PyObject *obj)
+ ARRAY *__rmod__(PyObject *obj)
{
const char msg[]="Unexpected situation in __rmod__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyRModulus(val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Modulus(aaaa,self);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Modulus(aaaa,self);
}
case 3:
{
- return DataArrayInt32::Modulus(a,self);
+ return ARRAY::Modulus(a,self);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Modulus(aaaa,self);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Modulus(aaaa,self);
}
default:
throw INTERP_KERNEL::Exception(msg);
PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
{
const char msg[]="Unexpected situation in __imod__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
self->modulusEqual(aaaa);
Py_XINCREF(trueSelf);
return trueSelf;
}
}
- DataArrayInt32 *__pow__(PyObject *obj)
+ ARRAY *__pow__(PyObject *obj)
{
const char msg[]="Unexpected situation in __pow__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyPow(val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Pow(self,aaaa);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Pow(self,aaaa);
}
case 3:
{
- return DataArrayInt32::Pow(self,a);
+ return ARRAY::Pow(self,a);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Pow(self,aaaa);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Pow(self,aaaa);
}
default:
throw INTERP_KERNEL::Exception(msg);
}
}
- DataArrayInt32 *__rpow__(PyObject *obj)
+ ARRAY *__rpow__(PyObject *obj)
{
const char msg[]="Unexpected situation in __rpow__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
{
case 1:
{
- MCAuto<DataArrayInt32> ret=self->deepCopy();
+ MCAuto<ARRAY> ret=self->deepCopy();
ret->applyRPow(val);
return ret.retn();
}
case 2:
{
- MCAuto<DataArrayInt32> aaaa=DataArrayInt32::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
- return DataArrayInt32::Pow(aaaa,self);
+ MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
+ return ARRAY::Pow(aaaa,self);
}
case 3:
{
- return DataArrayInt32::Pow(a,self);
+ return ARRAY::Pow(a,self);
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
- return DataArrayInt32::Pow(aaaa,self);
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ return ARRAY::Pow(aaaa,self);
}
default:
throw INTERP_KERNEL::Exception(msg);
PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
{
const char msg[]="Unexpected situation in __ipow__ !";
- int val;
- DataArrayInt32 *a;
- std::vector<int> aa;
- DataArrayInt32Tuple *aaa;
+ INT val;
+ ARRAY *a;
+ std::vector<INT> aa;
+ ARRAY ## Tuple *aaa;
mcIdType sw;
convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
switch(sw)
}
case 4:
{
- MCAuto<DataArrayInt32> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
+ MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
self->powEqual(aaaa);
Py_XINCREF(trueSelf);
return trueSelf;
void pushBackValsSilent(PyObject *li)
{
mcIdType szArr,sw;
- int iTypppArr;
- std::vector<int> stdvecTyyppArr;
- const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
+ INT iTypppArr;
+ std::vector<INT> stdvecTyyppArr;
+ const INT *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
self->pushBackValsSilent(tmp,tmp+szArr);
}
PyObject *partitionByDifferentValues() const
{
- std::vector<int> ret1;
+ std::vector<INT> ret1;
std::vector<DataArrayIdType *> ret0=self->partitionByDifferentValues(ret1);
std::size_t sz=ret0.size();
PyObject *pyRet=PyTuple_New(2);
- PyObject *pyRet0=PyList_New((int)sz);
- PyObject *pyRet1=PyList_New((int)sz);
+ PyObject *pyRet0=PyList_New((INT)sz);
+ PyObject *pyRet1=PyList_New((INT)sz);
for(std::size_t i=0;i<sz;i++)
{
PyList_SetItem(pyRet0,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret0[i]),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
return pyRet;
}
- PyObject *findIdsRangesInListOfIds(const DataArrayInt32 *listOfIds) const
+ PyObject *findIdsRangesInListOfIds(const ARRAY *listOfIds) const
{
DataArrayIdType *ret0=0;
- DataArrayInt32 *ret1=0;
+ ARRAY *ret1=0;
self->findIdsRangesInListOfIds(listOfIds,ret0,ret1);
PyObject *pyRet=PyTuple_New(2);
PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<int>::TI, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
return pyRet;
}
PyObject *isRange() const
{
- int a(0),b(0),c(0);
+ 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);
return pyRet;
}
- static bool RemoveIdsFromIndexedArrays(PyObject *li, DataArrayInt32 *arr, DataArrayIdType *arrIndx, mcIdType offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
+ static bool RemoveIdsFromIndexedArrays(PyObject *li, ARRAY *arr, DataArrayIdType *arrIndx, mcIdType offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
{
mcIdType sw;
- int singleVal;
- std::vector<int> multiVal;
+ INT singleVal;
+ std::vector<INT> multiVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
- MEDCoupling::DataArrayInt32 *daIntTyypp=0;
+ MEDCoupling::ARRAY *daIntTyypp=0;
if(!arrIndx)
- throw INTERP_KERNEL::Exception("DataArrayInt32::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
+ throw INTERP_KERNEL::Exception("ARRAY::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
- return DataArrayInt32::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
+ return ARRAY::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
case 2:
- return DataArrayInt32::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
+ return ARRAY::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
case 4:
- return DataArrayInt32::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
+ return ARRAY::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
default:
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt32 !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
}
}
- static PyObject *ExtractFromIndexedArrays(PyObject *li, const DataArrayInt32 *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
+ static PyObject *ExtractFromIndexedArrays(PyObject *li, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
{
- DataArrayInt32 *arrOut=0;
+ ARRAY *arrOut=0;
DataArrayIdType *arrIndexOut=0;
mcIdType sw;
mcIdType singleVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
MEDCoupling::DataArrayIdType *daIntTyypp=0;
if(!arrIndxIn)
- throw INTERP_KERNEL::Exception("DataArrayInt32::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
+ throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
{
- DataArrayInt32::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
+ ARRAY::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
break;
}
case 2:
{
- DataArrayInt32::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
+ ARRAY::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
break;
}
case 4:
{
- DataArrayInt32::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
+ ARRAY::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
break;
}
default:
- throw INTERP_KERNEL::Exception("DataArrayInt32::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt32 !");
+ throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
}
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
return ret;
}
- static PyObject *ExtractFromIndexedArraysSlice(mcIdType strt, mcIdType stp, mcIdType step, const DataArrayInt32 *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
+ static PyObject *ExtractFromIndexedArraysSlice(mcIdType strt, mcIdType stp, mcIdType step, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
{
- DataArrayInt32 *arrOut=0;
+ ARRAY *arrOut=0;
DataArrayIdType *arrIndexOut=0;
- DataArrayInt32::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
+ ARRAY::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
return ret;
}
- static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const DataArrayInt32 *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
+ static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
{
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
if(arrIndxIn->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
- DataArrayInt32 *arrOut=0;
+ ARRAY *arrOut=0;
DataArrayIdType *arrIndexOut=0;
- DataArrayInt32::ExtractFromIndexedArraysSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),arrIn,arrIndxIn,arrOut,arrIndexOut);
+ ARRAY::ExtractFromIndexedArraysSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),arrIn,arrIndxIn,arrOut,arrIndexOut);
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
}
static PyObject *SetPartOfIndexedArrays(PyObject *li,
- const DataArrayInt32 *arrIn, const DataArrayIdType *arrIndxIn,
- const DataArrayInt32 *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
+ const ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
+ const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
{
- DataArrayInt32 *arrOut=0;
+ ARRAY *arrOut=0;
DataArrayIdType *arrIndexOut=0;
mcIdType sw;
mcIdType singleVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
MEDCoupling::DataArrayIdType *daIntTyypp=0;
if(!arrIndxIn)
- throw INTERP_KERNEL::Exception("DataArrayInt32::SetPartOfIndexedArrays : null pointer as arrIndex !");
+ throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : null pointer as arrIndex !");
convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
{
- DataArrayInt32::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ ARRAY::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
break;
}
case 2:
{
- DataArrayInt32::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ ARRAY::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
break;
}
case 4:
{
- DataArrayInt32::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ ARRAY::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
break;
}
default:
- throw INTERP_KERNEL::Exception("DataArrayInt32::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt32 !");
+ throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
}
PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
return ret;
}
- static void SetPartOfIndexedArraysSameIdx(PyObject *li, DataArrayInt32 *arrIn, const DataArrayIdType *arrIndxIn,
- const DataArrayInt32 *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
+ static void SetPartOfIndexedArraysSameIdx(PyObject *li, ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
+ const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
{
mcIdType sw;
mcIdType singleVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
MEDCoupling::DataArrayIdType *daIntTyypp=0;
if(!arrIndxIn)
- throw INTERP_KERNEL::Exception("DataArrayInt32::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
+ throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
{
- DataArrayInt32::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
+ ARRAY::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
break;
}
case 2:
{
- DataArrayInt32::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
+ ARRAY::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
break;
}
case 4:
{
- DataArrayInt32::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
+ ARRAY::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
break;
}
default:
- throw INTERP_KERNEL::Exception("DataArrayInt32::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or DataArrayInt32 !");
+ throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
}
}
} // end extent
};
- class DataArrayInt32Tuple;
+ class ARRAY ## Tuple;
- class DataArrayInt32Iterator
+ class ARRAY ## Iterator
{
public:
- DataArrayInt32Iterator(DataArrayInt32 *da);
- ~DataArrayInt32Iterator();
+ ARRAY ## Iterator(ARRAY *da);
+ ~ARRAY ## Iterator();
%extend
{
PyObject *next()
{
- DataArrayInt32Tuple *ret=self->nextt();
+ ARRAY ## Tuple *ret=self->nextt();
if(ret)
- return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayInt32Tuple,SWIG_POINTER_OWN | 0);
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__ ## ARRAY ## Tuple,SWIG_POINTER_OWN | 0);
else
{
PyErr_SetString(PyExc_StopIteration,"No more data.");
}
};
- class DataArrayInt32Tuple
+ class ARRAY ## Tuple
{
public:
std::size_t getNumberOfCompo() const;
- DataArrayInt32 *buildDAInt(int nbOfTuples, int nbOfCompo) const;
+ ARRAY *buildDAInt(INT nbOfTuples, INT nbOfCompo) const;
%extend
{
std::string __str__() const
return self->repr();
}
- int __int__() const
+ INT __int__() const
{
return self->intValue();
}
- DataArrayInt32 *buildDAInt()
+ ARRAY *buildDAInt()
{
return self->buildDAInt(1,self->getNumberOfCompo());
}
PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
{
- MCAuto<DataArrayInt32> ret=self->buildDAInt(1,self->getNumberOfCompo());
- MEDCoupling_DataArrayInt32____iadd___(ret,0,obj);
+ MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ MEDCoupling_ ## ARRAY ## ____iadd___(ret,0,obj);
Py_XINCREF(trueSelf);
return trueSelf;
}
PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
{
- MCAuto<DataArrayInt32> ret=self->buildDAInt(1,self->getNumberOfCompo());
- MEDCoupling_DataArrayInt32____isub___(ret,0,obj);
+ MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ MEDCoupling_ ## ARRAY ## ____isub___(ret,0,obj);
Py_XINCREF(trueSelf);
return trueSelf;
}
PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
{
- MCAuto<DataArrayInt32> ret=self->buildDAInt(1,self->getNumberOfCompo());
- MEDCoupling_DataArrayInt32____imul___(ret,0,obj);
+ MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ MEDCoupling_ ## ARRAY ## ____imul___(ret,0,obj);
Py_XINCREF(trueSelf);
return trueSelf;
}
PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
{
- MCAuto<DataArrayInt32> ret=self->buildDAInt(1,self->getNumberOfCompo());
- MEDCoupling_DataArrayInt32____idiv___(ret,0,obj);
+ MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ MEDCoupling_ ## ARRAY ## ____idiv___(ret,0,obj);
Py_XINCREF(trueSelf);
return trueSelf;
}
PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
{
- MCAuto<DataArrayInt32> ret=self->buildDAInt(1,self->getNumberOfCompo());
- MEDCoupling_DataArrayInt32____imod___(ret,0,obj);
+ MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
+ MEDCoupling_ ## ARRAY ## ____imod___(ret,0,obj);
Py_XINCREF(trueSelf);
return trueSelf;
}
PyObject *__getitem__(PyObject *obj)
{
- const char msg2[]="DataArrayInt32Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
+ const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
mcIdType sw;
mcIdType singleVal;
std::vector<mcIdType> multiVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
MEDCoupling::DataArrayIdType *daIntTyypp=0;
- const int *pt=self->getConstPointer();
- int nbc=self->getNumberOfCompo();
+ const INT *pt=self->getConstPointer();
+ INT nbc=self->getNumberOfCompo();
convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 2:
{
PyObject *t=PyTuple_New(multiVal.size());
- for(int j=0;j<(int)multiVal.size();j++)
+ for(INT j=0;j<(INT)multiVal.size();j++)
{
- int cid=multiVal[j];
+ INT cid=multiVal[j];
if(cid>=nbc)
{
std::ostringstream oss;
}
case 3:
{
- int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
+ INT sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
PyObject *t=PyTuple_New(sz);
- for(int j=0;j<sz;j++)
+ for(INT j=0;j<sz;j++)
PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
return t;
}
default:
- throw INTERP_KERNEL::Exception("DataArrayInt32Tuple::__getitem__ : unrecognized type entered !");
+ throw INTERP_KERNEL::Exception("ARRAY ## Tuple::__getitem__ : unrecognized type entered !");
}
}
- DataArrayInt32Tuple *__setitem__(PyObject *obj, PyObject *value)
+ ARRAY ## Tuple *__setitem__(PyObject *obj, PyObject *value)
{
const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
mcIdType singleValV;
std::vector<mcIdType> multiValV;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
- MEDCoupling::DataArrayInt32Tuple *daIntTyyppV=0;
- int nbc=self->getNumberOfCompo();
- convertObjToPossibleCpp22<int>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
- int singleVal;
- std::vector<int> multiVal;
+ MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0;
+ INT nbc=self->getNumberOfCompo();
+ convertObjToPossibleCpp22<INT>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
+ INT singleVal;
+ std::vector<INT> multiVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
- MEDCoupling::DataArrayInt32 *daIntTyypp=0;
- int *pt=self->getPointer();
+ MEDCoupling::ARRAY *daIntTyypp=0;
+ INT *pt=self->getPointer();
convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
switch(sw2)
{
{
case 1:
{
- for(std::vector<int>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
+ for(std::vector<INT>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
{
if(*it>=nbc)
{
oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- for(int i=0;i<(int)multiVal.size();i++)
+ for(INT i=0;i<(INT)multiVal.size();i++)
{
- int pos=multiVal[i];
+ INT pos=multiVal[i];
if(pos>=nbc)
{
std::ostringstream oss;
}
case 4:
{
- const int *ptV=daIntTyyppV->getConstPointer();
- if(nbc>(int)daIntTyyppV->getNumberOfCompo())
+ const INT *ptV=daIntTyyppV->getConstPointer();
+ if(nbc>(INT)daIntTyyppV->getNumberOfCompo())
{
std::ostringstream oss;
oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
}
case 3:
{
- int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
+ INT sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
switch(sw1)
{
case 1:
{
- for(int j=0;j<sz;j++)
+ for(INT j=0;j<sz;j++)
pt[slic.first+j*slic.second.second]=singleValV;
return self;
}
case 2:
{
- if(sz!=(int)multiValV.size())
+ if(sz!=(INT)multiValV.size())
{
std::ostringstream oss;
oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- for(int j=0;j<sz;j++)
+ for(INT j=0;j<sz;j++)
pt[slic.first+j*slic.second.second]=multiValV[j];
return self;
}
case 4:
{
- const int *ptV=daIntTyyppV->getConstPointer();
- if(sz>(int)daIntTyyppV->getNumberOfCompo())
+ const INT *ptV=daIntTyyppV->getConstPointer();
+ if(sz>(INT)daIntTyyppV->getNumberOfCompo())
{
std::ostringstream oss;
oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- for(int j=0;j<sz;j++)
+ for(INT j=0;j<sz;j++)
pt[slic.first+j*slic.second.second]=ptV[j];
return self;
}
}
}
}
- };
-}
+// };
+// }
+%enddef
+%define TRANSFORMWITHINDARR( ARRAY, INT )
+void transformWithIndArr(PyObject *li)
+{
+ void *da=0;
+ int res1(SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 | 0 ));
+ if (!SWIG_IsOK(res1))
+ {
+ int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
+ if(SWIG_IsOK(res2))
+ {
+ MapII *m=reinterpret_cast<MapII *>(da);
+ self->transformWithIndArr(*m);
+ }
+ else
+ {
+ mcIdType size;
+ INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
+ self->transformWithIndArr(tmp,tmp+size);
+ }
+ }
+ else
+ {
+ ARRAY *da2=reinterpret_cast< ARRAY * >(da);
+ self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+}
+%enddef
+
namespace MEDCoupling
{
- class DataArrayInt64 : public DataArray
+ class DataArrayInt32Iterator;
+
+ class DataArrayInt32 : public DataArray
{
- public:
- static DataArrayInt64 *New();
- %extend
- {
- static DataArrayInt64 *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
- {
- const char *msgBase="MEDCoupling::DataArrayInt64::New : Available API are : \n-DataArrayInt64.New()\n-DataArrayInt64.New([1,3,4])\n-DataArrayInt64.New([1,3,4],3)\n-DataArrayInt64.New([1,3,4,5],2,2)\n-DataArrayInt64.New([1,3,4,5,7,8],3,2)\n-DataArrayInt64.New([(1,3),(4,5),(7,8)])\n-DataArrayInt64.New(5)\n-DataArrayInt64.New(5,2)";
- std::string msg(msgBase);
+ ARRAYDEF( DataArrayInt32, Int32 )
+ };
+ %extend DataArrayInt32 {
#ifdef WITH_NUMPY
- msg+="\n-DataArrayInt64.New(numpy array with dtype=int64)";
+ PyObject *toNumPyArray() // not const. It is not a bug !
+ {
+ return ToNumPyArray<DataArrayInt32,MEDCoupling::Int32>(self,NPY_INT32,"DataArrayInt32");
+ }
#endif
- msg+=" !";
- if(PyList_Check(elt0) || PyTuple_Check(elt0))
- {
- if(nbOfTuples)
- {
- if(PyInt_Check(nbOfTuples))
- {
- mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
- if(nbOfTuples1<0)
- throw INTERP_KERNEL::Exception("DataArrayInt64::New : should be a positive set of allocated memory !");
- if(nbOfComp)
- {
- if(PyInt_Check(nbOfComp))
- {//DataArrayInt64.New([1,3,4,5],2,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp);
- if(nbOfCompo<0)
- throw INTERP_KERNEL::Exception("DataArrayInt64::New : should be a positive number of components !");
- MCAuto<DataArrayInt64> ret=DataArrayInt64::New();
- std::vector<Int64> tmp=fillArrayWithPyListInt2<Int64>(elt0,nbOfTuples1,nbOfCompo);
- ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- return ret.retn();
- }
- else
- throw INTERP_KERNEL::Exception(msg.c_str());
- }
- else
- {//DataArrayInt64.New([1,3,4],3)
- MCAuto<DataArrayInt64> ret=DataArrayInt64::New();
- mcIdType tmpp1=-1;
- std::vector<Int64> tmp=fillArrayWithPyListInt2<Int64>(elt0,nbOfTuples1,tmpp1);
- ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- return ret.retn();
- }
- }
- else
- throw INTERP_KERNEL::Exception(msg.c_str());
- }
- else
- {// DataArrayInt64.New([1,3,4])
- MCAuto<DataArrayInt64> ret=DataArrayInt64::New();
- mcIdType tmpp1=-1,tmpp2=-1;
- std::vector<Int64> tmp=fillArrayWithPyListInt2<Int64>(elt0,tmpp1,tmpp2);
- ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- return ret.retn();
- }
- }
- else if(PyInt_Check(elt0))
- {
- int nbOfTuples1=PyInt_AS_LONG(elt0);
- if(nbOfTuples1<0)
- throw INTERP_KERNEL::Exception("DataArrayInt64::New : should be a positive set of allocated memory !");
- if(nbOfTuples)
- {
- if(!nbOfComp)
- {
- if(PyInt_Check(nbOfTuples))
- {//DataArrayInt64.New(5,2)
- int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
- if(nbOfCompo<0)
- throw INTERP_KERNEL::Exception("DataArrayInt64::New : should be a positive number of components !");
- MCAuto<DataArrayInt64> ret=DataArrayInt64::New();
- ret->alloc(nbOfTuples1,nbOfCompo);
- return ret.retn();
- }
- else
- throw INTERP_KERNEL::Exception(msg.c_str());
- }
- else
- throw INTERP_KERNEL::Exception(msg.c_str());
- }
- else
- {//DataArrayInt64.New(5)
- MCAuto<DataArrayInt64> ret=DataArrayInt64::New();
- ret->alloc(nbOfTuples1,1);
- return ret.retn();
- }
- }
-#ifdef WITH_NUMPY
- else if(PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
- {//DataArrayInt64.New(numpyArray)
- return BuildNewInstance<DataArrayInt64,Int64>(elt0,NPY_INT64,&PyCallBackDataArrayInt_RefType,"INT64");
- }
+#ifndef MEDCOUPLING_USE_64BIT_IDS
+ MCAuto< MapII > invertArrayN2O2O2NOptimized()
+ {
+ return self->invertArrayN2O2O2NOptimized();
+ }
+ MCAuto< MapII > giveN2OOptimized()
+ {
+ return self->giveN2OOptimized();
+ }
+ TRANSFORMWITHINDARR( DataArrayInt32, Int32 )
#endif
- else
- throw INTERP_KERNEL::Exception(msg.c_str());
- throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
- }
+ };
+
+ class DataArrayInt64Iterator;
+ class DataArrayInt64 : public DataArray
+ {
+ ARRAYDEF( DataArrayInt64, Int64 )
+ };
+ %extend DataArrayInt64 {
#ifdef WITH_NUMPY
- PyObject *toNumPyArray() // not const. It is not a bug !
- {
- return ToNumPyArray<DataArrayInt64,Int64>(self,NPY_INT64,"DataArrayInt64");
- }
+ PyObject *toNumPyArray() // not const. It is not a bug !
+ {
+ return ToNumPyArray<DataArrayInt64,MEDCoupling::Int64>(self,NPY_INT64,"DataArrayInt64");
+ }
#endif
+#ifdef MEDCOUPLING_USE_64BIT_IDS
+ MCAuto< MapII > invertArrayN2O2O2NOptimized()
+ {
+ return self->invertArrayN2O2O2NOptimized();
}
- };
-
- class DataArrayInt64Tuple;
-
- class DataArrayInt64Iterator
- {
- public:
- DataArrayInt64Iterator(DataArrayInt64 *da);
- ~DataArrayInt64Iterator();
- %extend
+ MCAuto< MapII > giveN2OOptimized()
{
- PyObject *next()
- {
- DataArrayInt64Tuple *ret=self->nextt();
- if(ret)
- return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayInt64Tuple,SWIG_POINTER_OWN | 0);
- else
- {
- PyErr_SetString(PyExc_StopIteration,"No more data.");
- return 0;
- }
- }
+ return self->giveN2OOptimized();
}
- };
-
- class DataArrayInt64Tuple
- {
- public:
- std::size_t getNumberOfCompo() const;
- DataArrayInt64 *buildDAInt(int nbOfTuples, int nbOfCompo) const;
- // %extend
- // {
- // std::string __str__() const
- // {
- // return self->repr();
- // }
-
- // int __int__() const
- // {
- // return self->intValue();
- // }
-
- // DataArrayInt64 *buildDAInt()
- // {
- // return self->buildDAInt(1,self->getNumberOfCompo());
- // }
-
- // PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
- // {
- // MCAuto<DataArrayInt64> ret=self->buildDAInt(1,self->getNumberOfCompo());
- // MEDCoupling_DataArrayInt64____iadd___(ret,0,obj);
- // Py_XINCREF(trueSelf);
- // return trueSelf;
- // }
-
- // PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
- // {
- // MCAuto<DataArrayInt64> ret=self->buildDAInt(1,self->getNumberOfCompo());
- // MEDCoupling_DataArrayInt64____isub___(ret,0,obj);
- // Py_XINCREF(trueSelf);
- // return trueSelf;
- // }
-
- // PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
- // {
- // MCAuto<DataArrayInt64> ret=self->buildDAInt(1,self->getNumberOfCompo());
- // MEDCoupling_DataArrayInt64____imul___(ret,0,obj);
- // Py_XINCREF(trueSelf);
- // return trueSelf;
- // }
- // PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
- // {
- // MCAuto<DataArrayInt64> ret=self->buildDAInt(1,self->getNumberOfCompo());
- // MEDCoupling_DataArrayInt64____idiv___(ret,0,obj);
- // Py_XINCREF(trueSelf);
- // return trueSelf;
- // }
-
- // PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
- // {
- // MCAuto<DataArrayInt64> ret=self->buildDAInt(1,self->getNumberOfCompo());
- // MEDCoupling_DataArrayInt64____imod___(ret,0,obj);
- // Py_XINCREF(trueSelf);
- // return trueSelf;
- // }
-
- // PyObject *__len__()
- // {
- // return PyInt_FromLong(self->getNumberOfCompo());
- // }
-
- // PyObject *__getitem__(PyObject *obj)
- // {
- // const char msg2[]="DataArrayInt64Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
- // mcIdType sw;
- // int singleVal;
- // std::vector<int> multiVal;
- // std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
- // MEDCoupling::DataArrayInt64 *daIntTyypp=0;
- // const int *pt=self->getConstPointer();
- // int nbc=self->getNumberOfCompo();
- // convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
- // switch(sw)
- // {
- // case 1:
- // {
- // if(singleVal>=nbc)
- // {
- // std::ostringstream oss;
- // oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
- // PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
- // return 0;
- // }
- // if(singleVal>=0)
- // return PyInt_FromLong(pt[singleVal]);
- // else
- // {
- // if(nbc+singleVal>0)
- // return PyInt_FromLong(pt[nbc+singleVal]);
- // else
- // {
- // std::ostringstream oss;
- // oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // }
- // }
- // case 2:
- // {
- // PyObject *t=PyTuple_New(multiVal.size());
- // for(int j=0;j<(int)multiVal.size();j++)
- // {
- // int cid=multiVal[j];
- // if(cid>=nbc)
- // {
- // std::ostringstream oss;
- // oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid]));
- // }
- // return t;
- // }
- // case 3:
- // {
- // int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
- // PyObject *t=PyTuple_New(sz);
- // for(int j=0;j<sz;j++)
- // PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
- // return t;
- // }
- // default:
- // throw INTERP_KERNEL::Exception("DataArrayInt64Tuple::__getitem__ : unrecognized type entered !");
- // }
- // }
-
- // DataArrayInt64Tuple *__setitem__(PyObject *obj, PyObject *value)
- // {
- // const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
- // const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
- // mcIdType sw1,sw2;
- // int singleValV;
- // std::vector<int> multiValV;
- // std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
- // MEDCoupling::DataArrayInt64Tuple *daIntTyyppV=0;
- // int nbc=self->getNumberOfCompo();
- // convertObjToPossibleCpp22(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
- // int singleVal;
- // std::vector<int> multiVal;
- // std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
- // MEDCoupling::DataArrayInt64 *daIntTyypp=0;
- // int *pt=self->getPointer();
- // convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
- // switch(sw2)
- // {
- // case 1:
- // {
- // if(singleVal>=nbc)
- // {
- // std::ostringstream oss;
- // oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // switch(sw1)
- // {
- // case 1:
- // {
- // pt[singleVal]=singleValV;
- // return self;
- // }
- // case 2:
- // {
- // if(multiValV.size()!=1)
- // {
- // std::ostringstream oss;
- // oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // pt[singleVal]=multiValV[0];
- // return self;
- // }
- // case 4:
- // {
- // pt[singleVal]=daIntTyyppV->getConstPointer()[0];
- // return self;
- // }
- // default:
- // throw INTERP_KERNEL::Exception(msg);
- // }
- // }
- // case 2:
- // {
- // switch(sw1)
- // {
- // case 1:
- // {
- // for(std::vector<int>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
- // {
- // if(*it>=nbc)
- // {
- // std::ostringstream oss;
- // oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // pt[*it]=singleValV;
- // }
- // return self;
- // }
- // case 2:
- // {
- // if(multiVal.size()!=multiValV.size())
- // {
- // std::ostringstream oss;
- // oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // for(int i=0;i<(int)multiVal.size();i++)
- // {
- // int pos=multiVal[i];
- // if(pos>=nbc)
- // {
- // std::ostringstream oss;
- // oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // pt[multiVal[i]]=multiValV[i];
- // }
- // return self;
- // }
- // case 4:
- // {
- // const int *ptV=daIntTyyppV->getConstPointer();
- // if(nbc>(int)daIntTyyppV->getNumberOfCompo())
- // {
- // std::ostringstream oss;
- // oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // std::copy(ptV,ptV+nbc,pt);
- // return self;
- // }
- // default:
- // throw INTERP_KERNEL::Exception(msg);
- // }
- // }
- // case 3:
- // {
- // int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
- // switch(sw1)
- // {
- // case 1:
- // {
- // for(int j=0;j<sz;j++)
- // pt[slic.first+j*slic.second.second]=singleValV;
- // return self;
- // }
- // case 2:
- // {
- // if(sz!=(int)multiValV.size())
- // {
- // std::ostringstream oss;
- // oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // for(int j=0;j<sz;j++)
- // pt[slic.first+j*slic.second.second]=multiValV[j];
- // return self;
- // }
- // case 4:
- // {
- // const int *ptV=daIntTyyppV->getConstPointer();
- // if(sz>(int)daIntTyyppV->getNumberOfCompo())
- // {
- // std::ostringstream oss;
- // oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
- // throw INTERP_KERNEL::Exception(oss.str().c_str());
- // }
- // for(int j=0;j<sz;j++)
- // pt[slic.first+j*slic.second.second]=ptV[j];
- // return self;
- // }
- // default:
- // throw INTERP_KERNEL::Exception(msg);
- // }
- // }
- // default:
- // throw INTERP_KERNEL::Exception(msg);
- // }
- // }
- // }
+ TRANSFORMWITHINDARR( DataArrayInt64, Int64 )
+#endif
};
}
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2019 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+
+import sys
+if sys.platform == "win32":
+ from MEDCouplingCompat import *
+else:
+ from medcoupling import *
+import unittest
+from math import pi,e,sqrt,cos,sin
+from datetime import datetime
+from MEDCouplingDataForTest import MEDCouplingDataForTest
+import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr
+
+class MEDCouplingBasicsTest7(unittest.TestCase):
+
+ def testDAIGetIdsEqual1(self):
+ tab1=[5,-2,-4,-2,3,2,-2];
+ da=DataArrayInt64.New();
+ da.setValues(tab1,7,1);
+ da2=da.findIdsEqual(-2);
+ self.assertEqual(3,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ expected1=[1,3,6];
+ self.assertEqual(expected1,da2.getValues());
+ pass
+
+ def testDAIGetIdsEqualList1(self):
+ tab1=[5,-2,-4,-2,3,2,-2];
+ da=DataArrayInt64.New();
+ da.setValues(tab1,7,1);
+ da2=da.findIdsEqualList([3,-2,0]);
+ self.assertEqual(4,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ expected1=[1,3,4,6];
+ self.assertEqual(expected1,da2.getValues());
+ pass
+
+ def testDAIsUniform1(self):
+ tab1=[1,1,1,1,1]
+ da=DataArrayInt64.New();
+ da.setValues(tab1,5,1);
+ self.assertTrue(da.isUniform(1));
+ da.setIJ(2,0,2);
+ self.assertTrue(not da.isUniform(1));
+ da.setIJ(2,0,1);
+ self.assertTrue(da.isUniform(1));
+ da2=da.convertToDblArr();
+ self.assertTrue(da2.isUniform(1.,1.e-12));
+ da2.setIJ(1,0,1.+1.e-13);
+ self.assertTrue(da2.isUniform(1.,1.e-12));
+ da2.setIJ(1,0,1.+1.e-11);
+ self.assertTrue(not da2.isUniform(1.,1.e-12));
+ pass
+
+ def testDAIBuildComplement1(self):
+ a=DataArrayInt64.New();
+ tab=[3,1,7,8]
+ a.setValues(tab,4,1);
+ b=a.buildComplement(12);
+ self.assertEqual(8,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[0,2,4,5,6,9,10,11]
+ for i in range(8):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIBuildUnion1(self):
+ a=DataArrayInt64.New();
+ tab1=[3,1,7,8]
+ a.setValues(tab1,4,1);
+ c=DataArrayInt64.New();
+ tab2=[5,3,0,18,8]
+ c.setValues(tab2,5,1);
+ b=a.buildUnion(c);
+ self.assertEqual(7,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[0,1,3,5,7,8,18]
+ for i in range(7):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ b=DataArrayInt64.BuildUnion([a,c]);
+ self.assertEqual(7,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[0,1,3,5,7,8,18]
+ for i in range(7):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIBuildIntersection1(self):
+ a=DataArrayInt64.New();
+ tab1=[3,1,7,8]
+ a.setValues(tab1,4,1);
+ c=DataArrayInt64.New();
+ tab2=[5,3,0,18,8]
+ c.setValues(tab2,5,1);
+ b=a.buildIntersection(c);
+ self.assertEqual(2,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[3,8]
+ for i in range(2):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ b=DataArrayInt64.BuildIntersection([a,c]);
+ self.assertEqual(2,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[3,8]
+ for i in range(2):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIDeltaShiftIndex1(self):
+ a=DataArrayInt64.New();
+ tab=[1,3,6,7,7,9,15]
+ a.setValues(tab,7,1);
+ b=a.deltaShiftIndex();
+ self.assertEqual(6,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[2,3,1,0,2,6]
+ for i in range(6):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIBuildSubstraction1(self):
+ a=DataArrayInt64.New()
+ aa=[2,3,6,8,9]
+ a.setValues(aa,5,1)
+ b=DataArrayInt64.New()
+ bb=[1,3,5,9,11]
+ b.setValues(bb,5,1)
+ self.assertEqual([2,6,8],a.buildSubstraction(b).getValues())
+ pass
+
+ def testDAIBuildPermutationArr1(self):
+ a=DataArrayInt64.New()
+ a.setValues([4,5,6,7,8],5,1)
+ b=DataArrayInt64.New()
+ b.setValues([5,4,8,6,7],5,1)
+ c=a.buildPermutationArr(b)
+ self.assertEqual([1,0,4,2,3],c.getValues())
+ self.assertTrue(a.isEqualWithoutConsideringStrAndOrder(b))
+ b.setIJ(0,0,9)
+ self.assertTrue(not a.isEqualWithoutConsideringStrAndOrder(b))
+ self.assertRaises(InterpKernelException,a.buildPermutationArr,b)
+ a.setIJ(3,0,4)
+ b.setIJ(0,0,5)
+ b.setIJ(4,0,4)#a==[4,5,6,4,8] and b==[5,4,8,6,4]
+ self.assertTrue(a.isEqualWithoutConsideringStrAndOrder(b))
+ c=a.buildPermutationArr(b)
+ self.assertEqual([1,3,4,2,3],c.getValues())
+ d=b.convertToDblArr()
+ expect3=[4,4,5,6,8]
+ b.sort()
+ self.assertEqual(expect3,b.getValues())
+ d.sort()
+ self.assertEqual(5,d.getNumberOfTuples());
+ self.assertEqual(1,d.getNumberOfComponents());
+ for i in range(5):
+ self.assertAlmostEqual(float(expect3[i]),d.getIJ(i,0),14);
+ pass
+ pass
+
+ def testDAIAggregateMulti1(self):
+ a=DataArrayInt64.New()
+ a.setValues(list(range(4)), 2, 2)
+ a.setName("aa")
+ b=DataArrayInt64.New()
+ b.setValues(list(range(6)), 3, 2)
+ c=DataArrayInt64.Aggregate([a,b])
+ self.assertEqual(list(range(4)) + list(range(6)), c.getValues())
+ self.assertEqual("aa",c.getName())
+ self.assertEqual(5,c.getNumberOfTuples())
+ self.assertEqual(2,c.getNumberOfComponents())
+ pass
+
+ def testDAICheckAndPreparePermutation1(self):
+ vals1=[9,10,0,6,4,11,3,7];
+ expect1=[5,6,0,3,2,7,1,4];
+ vals2=[9,10,0,6,10,11,3,7];
+ da=DataArrayInt64.New();
+ da.setValues(vals1,8,1);
+ da2=da.checkAndPreparePermutation();
+ self.assertEqual(8,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ for i in range(8):
+ self.assertEqual(expect1[i],da2.getIJ(i,0));
+ pass
+ #
+ da=DataArrayInt64.New();
+ da.alloc(8,1);
+ da.iota(0);
+ da2=da.checkAndPreparePermutation();
+ self.assertEqual(1,da2.getNumberOfComponents());
+ self.assertTrue(da2.isIota(8));
+ #
+ da=DataArrayInt64.New();
+ da.alloc(8,1);
+ da.setValues(vals2,8,1);
+ self.assertRaises(InterpKernelException,da.checkAndPreparePermutation);
+ pass
+
+ def testDAIChangeSurjectiveFormat1(self):
+ vals1=[0,3,2,3,2,2,1,2]
+ expected1=[0,1,2,6,8]
+ expected2=[0, 6, 2,4,5,7, 1,3]
+ da=DataArrayInt64.New();
+ da.setValues(vals1,8,1);
+ #
+ da2,da2I=da.changeSurjectiveFormat(4);
+ self.assertEqual(5,da2I.getNumberOfTuples());
+ self.assertEqual(8,da2.getNumberOfTuples());
+ self.assertEqual(expected1,da2I.getValues());
+ self.assertEqual(expected2,da2.getValues());
+ #
+ self.assertRaises(InterpKernelException,da.changeSurjectiveFormat,3);
+ #
+ pass
+
+ def testDAIGetIdsNotEqual1(self):
+ d=DataArrayInt64.New();
+ vals1=[2,3,5,6,8,5,5,6,1,-5]
+ d.setValues(vals1,10,1);
+ d2=d.findIdsNotEqual(5);
+ self.assertEqual(7,d2.getNumberOfTuples());
+ self.assertEqual(1,d2.getNumberOfComponents());
+ expected1=[0,1,3,4,7,8,9]
+ for i in range(7):
+ self.assertEqual(expected1[i],d2.getIJ(0,i));
+ pass
+ d.rearrange(2);
+ self.assertRaises(InterpKernelException,d.findIdsNotEqual,5);
+ vals2=[-4,5,6]
+ vals3=vals2;
+ d.rearrange(1);
+ d3=d.findIdsNotEqualList(vals3);
+ self.assertEqual(5,d3.getNumberOfTuples());
+ self.assertEqual(1,d3.getNumberOfComponents());
+ expected2=[0,1,4,8,9]
+ for i in range(5):
+ self.assertEqual(expected2[i],d3.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIComputeOffsets1(self):
+ d=DataArrayInt64.New();
+ vals1=[3,5,1,2,0,8]
+ expected1=[0,3,8,9,11,11]
+ d.setValues(vals1,6,1);
+ d.computeOffsets();
+ self.assertEqual(6,d.getNumberOfTuples());
+ self.assertEqual(1,d.getNumberOfComponents());
+ for i in range(6):
+ self.assertEqual(expected1[i],d.getIJ(0,i));
+ pass
+ pass
+
+ def testDAITransformWithIndArr1(self):
+ tab1=[17,18,22,19]
+ tab2=[0,1,1,3,3,0,1,3,2,2,3,0]
+ expected=[17,18,18,19,19,17,18,19,22,22,19,17]
+ d=DataArrayInt64.New();
+ d.setValues(tab1,4,1);
+ d1=DataArrayInt64.New();
+ d1.setValues(tab2,12,1);
+ d2=d1[:]
+ #
+ d1.transformWithIndArr(d);
+ self.assertEqual(12,d1.getNumberOfTuples());
+ self.assertEqual(1,d1.getNumberOfComponents());
+ for i in range(12):
+ self.assertEqual(expected[i],d1.getIJ(i,0));
+ pass
+ #
+ d1=d2
+ d1.transformWithIndArr(tab1)
+ self.assertEqual(12,d1.getNumberOfTuples());
+ self.assertEqual(1,d1.getNumberOfComponents());
+ for i in range(12):
+ self.assertEqual(expected[i],d1.getIJ(i,0));
+ pass
+ pass
+
+ def testDAIBuildPermArrPerLevel1(self):
+ arr=[2,0,1,1,0,1,2,0,1,1,0,0]
+ expected1=[10,0,5,6,1,7,11,2,8,9,3,4]
+ da=DataArrayInt64.New();
+ da.setValues(arr,12,1);
+ da2=da.buildPermArrPerLevel();
+ self.assertEqual(12,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ for i in range(12):
+ self.assertEqual(expected1[i],da2.getIJ(i,0));
+ pass
+ pass
+
+ def testDAIOperations1(self):
+ arr1=[-1,-2,4,7,3,2,6,6,4,3,0,1]
+ da=DataArrayInt64.New();
+ da.setValues(arr1,4,3);
+ da1=DataArrayInt64.New();
+ da1.alloc(12,1);
+ da1.iota(2);
+ self.assertRaises(InterpKernelException,DataArrayInt64.Add,da,da1);#not same number of tuples/Components
+ da1.rearrange(3);
+ da2=DataArrayInt64.Add(da,da1);
+ self.assertEqual(4,da2.getNumberOfTuples());
+ self.assertEqual(3,da2.getNumberOfComponents());
+ expected1=[1,1,8,12,9,9,14,15,14,14,12,14]
+ for i in range(12):
+ self.assertEqual(expected1[i],da2.getIJ(0,i));
+ pass
+ da1.substractEqual(da);
+ expected2=[3,5,0,-2,3,5,2,3,6,8,12,12]
+ for i in range(12):
+ self.assertEqual(expected2[i],da1.getIJ(0,i));
+ pass
+ da1.rearrange(1); da1.iota(2); da1.rearrange(3);
+ da1.addEqual(da);
+ for i in range(12):
+ self.assertEqual(expected1[i],da1.getIJ(0,i));
+ pass
+ da1.rearrange(1); da1.iota(2); da1.rearrange(3);
+ da2=DataArrayInt64.Multiply(da,da1);
+ self.assertEqual(4,da2.getNumberOfTuples());
+ self.assertEqual(3,da2.getNumberOfComponents());
+ expected3=[-2,-6,16,35,18,14,48,54,40,33,0,13]
+ for i in range(12):
+ self.assertEqual(expected3[i],da2.getIJ(0,i));
+ pass
+ da.divideEqual(da1);
+ self.assertEqual(4,da.getNumberOfTuples());
+ self.assertEqual(3,da.getNumberOfComponents());
+ expected4=[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
+ for i in range(12):
+ self.assertEqual(expected4[i],da.getIJ(0,i));
+ pass
+ da.setValues(arr1,4,3);
+ da1.multiplyEqual(da);
+ self.assertEqual(4,da1.getNumberOfTuples());
+ self.assertEqual(3,da1.getNumberOfComponents());
+ for i in range(12):
+ self.assertEqual(expected3[i],da1.getIJ(0,i));
+ pass
+ da1.rearrange(1); da1.iota(2); da1.rearrange(3);
+ da2=DataArrayInt64.Divide(da,da1);
+ self.assertEqual(4,da2.getNumberOfTuples());
+ self.assertEqual(3,da2.getNumberOfComponents());
+ for i in range(12):
+ self.assertEqual(expected4[i],da2.getIJ(0,i));
+ pass
+ da1.applyInv(321);
+ self.assertEqual(4,da1.getNumberOfTuples());
+ self.assertEqual(3,da1.getNumberOfComponents());
+ expected5=[160,107,80,64,53,45,40,35,32,29,26,24]
+ for i in range(12):
+ self.assertEqual(expected5[i],da1.getIJ(0,i));
+ pass
+ da1.applyDivideBy(2);
+ self.assertEqual(4,da1.getNumberOfTuples());
+ self.assertEqual(3,da1.getNumberOfComponents());
+ expected6=[80,53,40,32,26,22,20,17,16,14,13,12]
+ for i in range(12):
+ self.assertEqual(expected6[i],da1.getIJ(0,i));
+ pass
+ expected7=[3,4,5,4,5,1,6,3,2,0,6,5]
+ da1.applyModulus(7);
+ for i in range(12):
+ self.assertEqual(expected7[i],da1.getIJ(0,i));
+ pass
+ da1.applyLin(1,1);
+ expected8=[3,3,3,3,3,1,3,3,0,0,3,3]
+ da1.applyRModulus(3);
+ for i in range(12):
+ self.assertEqual(expected8[i],da1.getIJ(0,i));
+ pass
+ pass
+
+ def testDAITransformWithIndArrR1(self):
+ tab1=[2,4,5,3,6,7]
+ tab2=[-1,-1,0,1,2,3,4,5,-1,-1,-1,-1]
+ expected=[0,3,1,2,4,5]
+ d=DataArrayInt64.New();
+ d.setValues(tab1,6,1);
+ d1=DataArrayInt64.New();
+ d1.setValues(tab2,12,1);
+ d2=d1[:]
+ #
+ d3=d.transformWithIndArrR(d1);
+ self.assertEqual(6,d3.getNumberOfTuples());
+ self.assertEqual(1,d3.getNumberOfComponents());
+ for i in range(6):
+ self.assertEqual(expected[i],d3.getIJ(i,0));
+ pass
+ #
+ d1=d2
+ d3=d.transformWithIndArrR(tab2)
+ self.assertEqual(6,d3.getNumberOfTuples());
+ self.assertEqual(1,d3.getNumberOfComponents());
+ for i in range(6):
+ self.assertEqual(expected[i],d3.getIJ(i,0));
+ pass
+ pass
+
+ def testDAISplitByValueRange1(self):
+ val1=[6,5,0,3,2,7,8,1,4]
+ val2=[0,4,9]
+ d=DataArrayInt64.New();
+ d.setValues(val1,9,1);
+ e,f,g=d.splitByValueRange(val2);
+ self.assertEqual(9,e.getNumberOfTuples());
+ self.assertEqual(1,e.getNumberOfComponents());
+ self.assertEqual(9,f.getNumberOfTuples());
+ self.assertEqual(1,f.getNumberOfComponents());
+ self.assertEqual(2,g.getNumberOfTuples());
+ self.assertEqual(1,g.getNumberOfComponents());
+ #
+ expected1=[1,1,0,0,0,1,1,0,1]
+ expected2=[2,1,0,3,2,3,4,1,0]
+ for i in range(9):
+ self.assertEqual(expected1[i],e.getIJ(i,0));
+ self.assertEqual(expected2[i],f.getIJ(i,0));
+ pass
+ self.assertEqual(0,g.getIJ(0,0));
+ self.assertEqual(1,g.getIJ(1,0));
+ #
+ d.setIJ(6,0,9);
+ self.assertRaises(InterpKernelException,d.splitByValueRange,val2);
+ # non regression test in python wrapping
+ rg=DataArrayInt64([0,10,29,56,75,102,121,148,167,194,213,240,259,286,305,332,351,378,397,424,443,470,489,516])
+ a,b,c=DataArrayInt64([75]).splitByValueRange(rg)
+ assert(a.isEqual(DataArrayInt64([4])))
+ assert(b.isEqual(DataArrayInt64([0])))
+ assert(c.isEqual(DataArrayInt64([4])))
+ pass
+
+ def testDAIBuildExplicitArrByRanges1(self):
+ d=DataArrayInt64.New();
+ vals1=[0,2,3]
+ d.setValues(vals1,3,1);
+ e=DataArrayInt64.New();
+ vals2=[0,3,6,10,14,20]
+ e.setValues(vals2,6,1);
+ #
+ f=d.buildExplicitArrByRanges(e);
+ self.assertEqual(11,f.getNumberOfTuples());
+ self.assertEqual(1,f.getNumberOfComponents());
+ expected1=[0,1,2,6,7,8,9,10,11,12,13]
+ for i in range(11):
+ self.assertEqual(expected1[i],f.getIJ(i,0));
+ pass
+ pass
+
+ def testDAIComputeOffsets2(self):
+ d=DataArrayInt64.New();
+ vals1=[3,5,1,2,0,8]
+ expected1=[0,3,8,9,11,11,19]
+ d.setValues(vals1,6,1);
+ d.computeOffsetsFull();
+ self.assertEqual(7,d.getNumberOfTuples());
+ self.assertEqual(1,d.getNumberOfComponents());
+ for i in range(7):
+ self.assertEqual(expected1[i],d.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIBuildOld2NewArrayFromSurjectiveFormat2(self):
+ arr=[0,3, 5,7,9]
+ arrI=[0,2,5]
+ a=DataArrayInt64.New();
+ a.setValues(arr,5,1);
+ b=DataArrayInt64.New();
+ b.setValues(arrI,3,1);
+ ret,newNbTuple=DataArrayInt64.ConvertIndexArrayToO2N(10,a,b);
+ expected=[0,1,2,0,3,4,5,4,6,4]
+ self.assertEqual(10,ret.getNbOfElems());
+ self.assertEqual(7,newNbTuple);
+ self.assertEqual(1,ret.getNumberOfComponents());
+ self.assertEqual(expected,ret.getValues());
+ self.assertRaises(InterpKernelException,DataArrayInt64.ConvertIndexArrayToO2N,9,a,b);
+ pass
+
+ def testDAIBuildUnique1(self):
+ d=DataArrayInt64([1,2,2,3,3,3,3,4,5,5,7,7,7,19])
+ e=d.buildUnique()
+ self.assertTrue(e.isEqual(DataArrayInt64([1,2,3,4,5,7,19])))
+ pass
+
+ def testDAIPartitionByDifferentValues1(self):
+ d=DataArrayInt64([1,0,1,2,0,2,2,-3,2])
+ expected=[[-3,[7]],[0,[1,4]],[1,[0,2]],[2,[3,5,6,8]]]
+ for i,elt in enumerate(zip(*d.partitionByDifferentValues())):
+ self.assertEqual(expected[i][0],elt[1])
+ self.assertEqual(expected[i][1],elt[0].getValues())
+ pass
+ pass
+
+ def testDAICheckMonotonic1(self):
+ data1=[-1,0,2,2,4,5]
+ data2=[6,2,0,-8,-9,-56]
+ data3=[-1,0,3,2,4,6]
+ data4=[7,5,2,3,0,-6]
+ d=DataArrayInt64.New(data1);
+ self.assertTrue(d.isMonotonic(True));
+ self.assertTrue(not d.isMonotonic(False));
+ d.checkMonotonic(True);
+ self.assertRaises(InterpKernelException,d.checkMonotonic,False)
+ d=DataArrayInt64.New(data2);
+ self.assertTrue(d.isMonotonic(False));
+ self.assertTrue(not d.isMonotonic(True));
+ d.checkMonotonic(False);
+ self.assertRaises(InterpKernelException,d.checkMonotonic,True)
+ d=DataArrayInt64.New(data3);
+ self.assertTrue(not d.isMonotonic(False));
+ self.assertTrue(not d.isMonotonic(True));
+ self.assertRaises(InterpKernelException,d.checkMonotonic,True)
+ self.assertRaises(InterpKernelException,d.checkMonotonic,False)
+ d=DataArrayInt64.New(data4);
+ self.assertTrue(not d.isMonotonic(False));
+ self.assertTrue(not d.isMonotonic(True));
+ self.assertRaises(InterpKernelException,d.checkMonotonic,True)
+ self.assertRaises(InterpKernelException,d.checkMonotonic,False)
+ d=DataArrayInt64.New(0,1)
+ self.assertTrue(d.isMonotonic(True));
+ self.assertTrue(d.isMonotonic(False));
+ d.checkMonotonic(True);
+ d.checkMonotonic(False);
+ d=DataArrayInt64.New(data4,3,2);#throw because nbComp!=1
+ self.assertRaises(InterpKernelException,d.isMonotonic,True)
+ self.assertRaises(InterpKernelException,d.isMonotonic,False)
+ self.assertRaises(InterpKernelException,d.checkMonotonic,True)
+ self.assertRaises(InterpKernelException,d.checkMonotonic,False)
+ pass
+
+ def testDAIBuildSubstractionOptimized1(self):
+ da1=DataArrayInt64.New([1,3,5,6,7,9,13])
+ da2=DataArrayInt64.New([3,5,9])
+ da3=DataArrayInt64.New([1,3,5])
+ da4=DataArrayInt64.New([1,3,5,6,7,9,13])
+ #
+ a=da1.buildSubstractionOptimized(da2);
+ self.assertTrue(a.isEqual(DataArrayInt64([1,6,7,13])));
+ #
+ a=da1.buildSubstractionOptimized(da3);
+ self.assertTrue(a.isEqual(DataArrayInt64([6,7,9,13])));
+ #
+ a=da1.buildSubstractionOptimized(da4);
+ self.assertTrue(a.isEqual(DataArrayInt64([])));
+ pass
+
+ def testDAIIsStrictlyMonotonic1(self):
+ da1=DataArrayInt64.New([1,3,5,6,7,9,13])
+ self.assertTrue(da1.isStrictlyMonotonic(True));
+ da1.checkStrictlyMonotonic(True);
+ self.assertTrue(da1.isMonotonic(True));
+ da1.checkMonotonic(True);
+ self.assertTrue(not da1.isStrictlyMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,False)
+ self.assertTrue(not da1.isMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkMonotonic,False)
+ #
+ da1=DataArrayInt64.New([1,3,5,6,6,9,13])
+ self.assertTrue(not da1.isStrictlyMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,True)
+ self.assertTrue(da1.isMonotonic(True));
+ da1.checkMonotonic(True);
+ self.assertTrue(not da1.isStrictlyMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,False)
+ self.assertTrue(not da1.isMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkMonotonic,False)
+ #
+ da1=DataArrayInt64.New([1,3,5,6,5,9,13])
+ self.assertTrue(not da1.isStrictlyMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,True)
+ self.assertTrue(not da1.isMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkMonotonic,True)
+ self.assertTrue(not da1.isStrictlyMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,False)
+ self.assertTrue(not da1.isMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkMonotonic,False)
+ #
+ da1=DataArrayInt64.New([13,9,7,6,5,3,1])
+ self.assertTrue(not da1.isStrictlyMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,True)
+ self.assertTrue(not da1.isMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkMonotonic,True)
+ self.assertTrue(da1.isStrictlyMonotonic(False));
+ da1.checkStrictlyMonotonic(False);
+ self.assertTrue(da1.isMonotonic(False));
+ da1.checkMonotonic(False);
+ #
+ da1=DataArrayInt64.New([13,9,6,6,5,3,1])
+ self.assertTrue(not da1.isStrictlyMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,True)
+ self.assertTrue(not da1.isMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkMonotonic,True)
+ self.assertTrue(not da1.isStrictlyMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,False)
+ self.assertTrue(da1.isMonotonic(False));
+ da1.checkMonotonic(False);
+ #
+ da1=DataArrayInt64.New([13,9,5,6,5,3,1])
+ self.assertTrue(not da1.isStrictlyMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,True)
+ self.assertTrue(not da1.isMonotonic(True));
+ self.assertRaises(InterpKernelException,da1.checkMonotonic,True)
+ self.assertTrue(not da1.isStrictlyMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkStrictlyMonotonic,False)
+ self.assertTrue(not da1.isMonotonic(False));
+ self.assertRaises(InterpKernelException,da1.checkMonotonic,False)
+ #
+ da1=DataArrayInt64.New([])
+ self.assertTrue(da1.isStrictlyMonotonic(True));
+ da1.checkStrictlyMonotonic(True);
+ self.assertTrue(da1.isMonotonic(True));
+ da1.checkMonotonic(True);
+ self.assertTrue(da1.isStrictlyMonotonic(False));
+ da1.checkStrictlyMonotonic(False);
+ self.assertTrue(da1.isMonotonic(False));
+ da1.checkMonotonic(False);
+ #
+ da1=DataArrayInt64.New([13])
+ self.assertTrue(da1.isStrictlyMonotonic(True));
+ da1.checkStrictlyMonotonic(True);
+ self.assertTrue(da1.isMonotonic(True));
+ da1.checkMonotonic(True);
+ self.assertTrue(da1.isStrictlyMonotonic(False));
+ da1.checkStrictlyMonotonic(False);
+ self.assertTrue(da1.isMonotonic(False));
+ da1.checkMonotonic(False);
+ pass
+
+ def testDAIIndicesOfSubPart(self):
+ a=DataArrayInt64([9,10,0,6,4,11,3,8])
+ b=DataArrayInt64([6,0,11,8])
+ c=a.indicesOfSubPart(b)
+ self.assertTrue(c.isEqual(DataArrayInt64([3,2,5,7])))
+ #
+ d=DataArrayInt64([9,10,0,6,4,11,0,8])
+ self.assertRaises(InterpKernelException,d.indicesOfSubPart,b) # 0 appears twice in the d array
+ f=DataArrayInt64([6,0,11,8,12])
+ self.assertRaises(InterpKernelException,a.indicesOfSubPart,f) # 12 in f does not exist in a
+ pass
+
+ def testDAIFromLinkedListOfPairToList1(self):
+ d=DataArrayInt64([(5,7),(7,3),(3,12),(12,17)])
+ zeRes=DataArrayInt64([5,7,3,12,17])
+ self.assertTrue(d.fromLinkedListOfPairToList().isEqual(zeRes))
+ d.rearrange(1)
+ self.assertRaises(InterpKernelException,d.fromLinkedListOfPairToList)
+ d.rearrange(2)
+ self.assertTrue(d.fromLinkedListOfPairToList().isEqual(zeRes))
+ d2=DataArrayInt64([(5,7)])
+ self.assertTrue(d2.fromLinkedListOfPairToList().isEqual(DataArrayInt64([5,7])))
+ d3=DataArrayInt64([(5,7),(7,3),(4,12),(12,17)])
+ self.assertRaises(InterpKernelException,d3.fromLinkedListOfPairToList) # not a linked list of pair
+ d4=DataArrayInt64([(5,7),(7,3),(12,3),(12,17)])
+ self.assertRaises(InterpKernelException,d4.fromLinkedListOfPairToList) # not a linked list of pair, but can be repaired !
+ d4.sortEachPairToMakeALinkedList()
+ self.assertTrue(d4.fromLinkedListOfPairToList().isEqual(zeRes))
+ pass
+
+ def testDAIfindIdsExt1(self):
+ d=DataArrayInt64([4,6,-2,3,7,0,10])
+ self.assertTrue(d.findIdsGreaterOrEqualTo(3).isEqual(DataArrayInt64([0,1,3,4,6])))
+ self.assertTrue(d.findIdsGreaterThan(3).isEqual(DataArrayInt64([0,1,4,6])))
+ self.assertTrue(d.findIdsLowerThan(3).isEqual(DataArrayInt64([2,5])))
+ self.assertTrue(d.findIdsLowerOrEqualTo(3).isEqual(DataArrayInt64([2,3,5])))
+ pass
+
+ def testDAICheckUniformAndGuess1(self):
+ d=DataArrayInt64([3,3],1,2)
+ self.assertRaises(InterpKernelException,d.checkUniformAndGuess)# non single compo
+ d=DataArrayInt64([])
+ self.assertRaises(InterpKernelException,d.checkUniformAndGuess)# empty
+ d=DataArrayInt64()
+ self.assertRaises(InterpKernelException,d.checkUniformAndGuess)# non allocated
+ d=DataArrayInt64([3,3,3])
+ self.assertEqual(3,d.checkUniformAndGuess())
+ d=DataArrayInt64([7])
+ self.assertEqual(7,d.checkUniformAndGuess())
+ d=DataArrayInt64([3,4,3])
+ self.assertRaises(InterpKernelException,d.checkUniformAndGuess)# non uniform
+ pass
+
+ def testDAIFindIdForEach1(self):
+ a1=DataArrayInt64([17,27,2,10,-4,3,12,27,16])
+ b1=DataArrayInt64([3,16,-4,27,17])
+ ret=a1.findIdForEach(b1)
+ self.assertTrue(ret.isEqual(DataArrayInt64([5,8,4,7,0])))
+ self.assertTrue(a1[ret].isEqual(b1))
+ b2=DataArrayInt64([3,16,22,27,17])
+ self.assertRaises(InterpKernelException,a1.findIdForEach,b2) # 22 not in a1 !
+ a1.rearrange(3)
+ self.assertRaises(InterpKernelException,a1.findIdForEach,b1) # a1 is not single component
+ pass
+
+ pass
+
+if __name__ == '__main__':
+ unittest.main()