]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
On the road
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 26 Apr 2017 10:09:11 +0000 (12:09 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 26 Apr 2017 10:09:11 +0000 (12:09 +0200)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingMemArray.txx
src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i
src/MEDCoupling_Swig/MEDCouplingMemArray.i
src/MEDCoupling_Swig/MEDCouplingNumPyTest.py

index 06ab8e47d4a60e3d0869f20fcdf86411f0b6f895..4b5da2176995172b21e0bb616137f43e513e7c33 100644 (file)
@@ -40,6 +40,7 @@ template class MEDCoupling::MemArray<int>;
 template class MEDCoupling::MemArray<double>;
 template class MEDCoupling::DataArrayTemplate<int>;
 template class MEDCoupling::DataArrayTemplate<double>;
+template class MEDCoupling::DataArrayTemplateFP<double>;
 
 template<int SPACEDIM>
 void DataArrayDouble::findCommonTuplesAlg(const double *bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt *c, DataArrayInt *cI) const
@@ -849,31 +850,6 @@ void DataArrayDouble::iota(double init)
   declareAsNew();
 }
 
-/*!
- * Checks if all values in \a this array are equal to \a val at precision \a eps.
- *  \param [in] val - value to check equality of array values to.
- *  \param [in] eps - precision to check the equality.
- *  \return bool - \a true if all values are in range (_val_ - _eps_; _val_ + _eps_),
- *                 \a false else.
- *  \throw If \a this->getNumberOfComponents() != 1
- *  \throw If \a this is not allocated.
- */
-bool DataArrayDouble::isUniform(double val, double eps) const
-{
-  checkAllocated();
-  if(getNumberOfComponents()!=1)
-    throw INTERP_KERNEL::Exception("DataArrayDouble::isUniform : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
-  int nbOfTuples=getNumberOfTuples();
-  const double *w=getConstPointer();
-  const double *end2=w+nbOfTuples;
-  const double vmin=val-eps;
-  const double vmax=val+eps;
-  for(;w!=end2;w++)
-    if(*w<vmin || *w>vmax)
-      return false;
-  return true;
-}
-
 /*!
  * Checks that \a this array is consistently **increasing** or **decreasing** in value,
  * with at least absolute difference value of |\a eps| at each step.
index e06721f527aa04b4a7b5e2ff5b133964cdeed3d7..76dae5355053aaccc7a10f0cd9c947323104194e 100644 (file)
@@ -296,11 +296,18 @@ namespace MEDCoupling
   protected:
     MemArray<T> _mem;
   };
+
+  template<class T>
+  class DataArrayTemplateFP : public DataArrayTemplate<T>
+  {
+  public:
+    MEDCOUPLING_EXPORT bool isUniform(T val, T eps) const;
+  };
 }
 
 namespace MEDCoupling
 {
-  class DataArrayFloat : public DataArrayTemplate<float>
+  class DataArrayFloat : public DataArrayTemplateFP<float>
   {
   public:
     MEDCOUPLING_EXPORT static DataArrayFloat *New();
@@ -322,6 +329,10 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
     MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
     MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
+  public:
+    MEDCOUPLING_EXPORT bool isEqual(const DataArrayFloat& other, float prec) const;
+    MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const;
+    MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const;
   private:
     ~DataArrayFloat() { }
     DataArrayFloat() { }
@@ -331,7 +342,7 @@ namespace MEDCoupling
 namespace MEDCoupling
 {
   class DataArrayDoubleIterator;
-  class DataArrayDouble : public DataArrayTemplate<double>
+  class DataArrayDouble : public DataArrayTemplateFP<double>
   {
   public:
     MEDCOUPLING_EXPORT static DataArrayDouble *New();
@@ -341,7 +352,6 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT DataArrayDouble *performCopyOrIncrRef(bool deepCopy) const;
     MEDCOUPLING_EXPORT void fillWithZero();
     MEDCOUPLING_EXPORT void iota(double init=0.);
-    MEDCOUPLING_EXPORT bool isUniform(double val, double eps) const;
     MEDCOUPLING_EXPORT void checkMonotonic(bool increasing, double eps) const;
     MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const;
     MEDCOUPLING_EXPORT std::string repr() const;
index 5df4f7150b71637dd40bcf3af923036533ed8d9b..317ab3c0b5ef1f2b55da05028074ca77921aaba7 100644 (file)
@@ -2252,6 +2252,30 @@ namespace MEDCoupling
       std::reverse(work,work+nbOfCompo);
     std::reverse(_info_on_compo.begin(),_info_on_compo.end());
   }
+  
+  /*!
+   * Checks if all values in \a this array are equal to \a val at precision \a eps.
+   *  \param [in] val - value to check equality of array values to.
+   *  \param [in] eps - precision to check the equality.
+   *  \return bool - \a true if all values are in range (_val_ - _eps_; _val_ + _eps_),
+   *                 \a false else.
+   *  \throw If \a this->getNumberOfComponents() != 1
+   *  \throw If \a this is not allocated.
+   */
+  template<class T>
+  bool DataArrayTemplateFP<T>::isUniform(T val, T eps) const
+  {
+    DataArrayTemplate<T>::checkAllocated();
+    if(DataArrayTemplate<T>::getNumberOfComponents()!=1)
+      throw INTERP_KERNEL::Exception("DataArrayDouble::isUniform : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
+    int nbOfTuples(DataArrayTemplate<T>::getNumberOfTuples());
+    const T *w(DataArrayTemplate<T>::begin()),*end2(DataArrayTemplate<T>::end());
+    const T vmin(val-eps),vmax(val+eps);
+    for(;w!=end2;w++)
+      if(*w<vmin || *w>vmax)
+        return false;
+    return true;
+  }
 }
 
 #endif
index 1b71f2493b3d074ab8a4b6d9fe70c2a10c0b80cb..2e41183131dc075c19b0ac2c3315850adc645eaa 100644 (file)
@@ -1346,18 +1346,19 @@ static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std:
  *
  * switch between (int,vector<int>,DataArrayInt)
  */
-static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, MEDCoupling::DataArrayDouble *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+template<class T>
+void convertObjToPossibleCpp4(PyObject *value, int& sw, T& iTyypp, std::vector<T>& stdvecTyypp, typename MEDCoupling::Traits<T>::ArrayType *& daIntTyypp, swig_type_info *ti) throw(INTERP_KERNEL::Exception)
 {
   sw=-1;
   if(PyFloat_Check(value))
     {
-      iTyypp=PyFloat_AS_DOUBLE(value);
+      iTyypp=(T)PyFloat_AS_DOUBLE(value);
       sw=1;
       return;
     }
   if(PyInt_Check(value))
     {
-      iTyypp=(double)PyInt_AS_LONG(value);
+      iTyypp=(T)PyInt_AS_LONG(value);
       sw=1;
       return;
     }
@@ -1369,9 +1370,9 @@ static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, s
         {
           PyObject *o=PyTuple_GetItem(value,i);
           if(PyFloat_Check(o))
-            stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
+            stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
           else if(PyInt_Check(o))
-            stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
+            stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
           else
             {
               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
@@ -1389,9 +1390,9 @@ static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, s
         {
           PyObject *o=PyList_GetItem(value,i);
           if(PyFloat_Check(o))
-            stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
+            stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
           else if(PyInt_Check(o))
-            stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
+            stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
           else
             {
               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
@@ -1402,10 +1403,10 @@ static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, s
       return;
     }
   void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
+  int status=SWIG_ConvertPtr(value,&argp,ti,0|0);
   if(!SWIG_IsOK(status))
     throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
-  daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
+  daIntTyypp=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayType * >(argp);
   sw=3;
 }
 
@@ -2537,4 +2538,371 @@ static typename MEDCoupling::Traits<T>::ArrayType *DataArrayT_New(PyObject *elt0
   throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
 }
 
+template<class T>
+typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__internal(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value, swig_type_info *ti)
+{
+  self->checkAllocated();
+  const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
+  int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
+  int sw1,sw2;
+  T i1;
+  std::vector<T> v1;
+  typename MEDCoupling::Traits<T>::ArrayType *d1=0;
+  convertObjToPossibleCpp4<T>(value,sw1,i1,v1,d1,ti);
+  int it1,ic1;
+  std::vector<int> vt1,vc1;
+  std::pair<int, std::pair<int,int> > pt1,pc1;
+  MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
+  convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+  MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > tmp;
+  switch(sw2)
+    {
+    case 1:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
+            return self;
+          case 3:
+            self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 2:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
+            return self;
+          case 3:
+            self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 3:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
+            return self;
+          case 3:
+            self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 4:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
+            return self;
+          case 3:
+            self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 5:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
+            return self;
+          case 3:
+            self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 6:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
+            return self;
+          case 3:
+            self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 7:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
+            return self;
+          case 3:
+            self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 8:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
+            return self;
+          case 3:
+            self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 9:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
+            return self;
+          case 3:
+            self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 10:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+            return self;
+          case 3:
+            self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 11:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::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;
+          case 3:
+            self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 12:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
+            return self;
+          case 3:
+            self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 13:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+            self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
+            return self;
+          case 3:
+            self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 14:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::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;
+          case 3:
+            self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 15:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::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;
+          case 3:
+            self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    case 16:
+      {
+        switch(sw1)
+          {
+          case 1:
+            self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+            return self;
+          case 2:
+            tmp=MEDCoupling::Traits<T>::ArrayType::New();
+            tmp->useArray(&v1[0],false,MEDCoupling::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;
+          case 3:
+            self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+            return self;
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        break;
+      }
+    default:
+      throw INTERP_KERNEL::Exception(msg);
+    }
+  return self;
+}
+
+template<class T>
+struct SWIGTITraits
+{ };
+
+template<>
+struct SWIGTITraits<double>
+{ static swig_type_info *TI; };
+
+template<>
+struct SWIGTITraits<float>
+{ static swig_type_info *TI; };
+
+swig_type_info *SWIGTITraits<double>::TI=SWIGTYPE_p_MEDCoupling__DataArrayDouble;
+
+swig_type_info *SWIGTITraits<float>::TI=SWIGTYPE_p_MEDCoupling__DataArrayFloat;
+
+template<class T>
+typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value)
+{
+  return DataArrayT__setitem__internal<T>(self,obj,value,SWIGTITraits<T>::TI);
+}
+
 #endif
index fc31cd2104ef570b7f78c732a8550b780b632f06..94c9873e06020f665ef01c52bd50e18f6c67f60c 100644 (file)
@@ -663,6 +663,11 @@ namespace MEDCoupling
   {
   public:
     static DataArrayFloat *New();
+    void fillWithValue(float val) throw(INTERP_KERNEL::Exception);
+    bool isEqual(const DataArrayFloat& other, float prec) const throw(INTERP_KERNEL::Exception);
+    bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const throw(INTERP_KERNEL::Exception);
+    bool isUniform(float val, float eps) const throw(INTERP_KERNEL::Exception);
+    void pushBackSilent(float val) throw(INTERP_KERNEL::Exception);
     %extend
     {
       DataArrayFloat() throw(INTERP_KERNEL::Exception)
@@ -716,6 +721,11 @@ namespace MEDCoupling
         int nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples());
         return convertDblArrToPyListOfTuple<float>(vals,nbOfComp,nbOfTuples);
       }
+
+      DataArrayFloat *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
+      {
+        return DataArrayT__setitem__<float>(self,obj,value);
+      }
       
 #ifdef WITH_NUMPY
       PyObject *toNumPyArray() throw(INTERP_KERNEL::Exception) // not const. It is not a bug !
@@ -1406,347 +1416,7 @@ namespace MEDCoupling
 
       DataArrayDouble *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
       {
-        self->checkAllocated();
-        const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
-        int nbOfTuples=self->getNumberOfTuples();
-        int nbOfComponents=self->getNumberOfComponents();
-        int sw1,sw2;
-        double i1;
-        std::vector<double> v1;
-        DataArrayDouble *d1=0;
-        convertObjToPossibleCpp4(value,sw1,i1,v1,d1);
-        int it1,ic1;
-        std::vector<int> vt1,vc1;
-        std::pair<int, std::pair<int,int> > pt1,pc1;
-        DataArrayInt *dt1=0,*dc1=0;
-        convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
-        MCAuto<DataArrayDouble> tmp;
-        switch(sw2)
-          {
-          case 1:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 2:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 3:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 4:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 5:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 6:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 7:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 8:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 9:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
-                  return self;
-                case 3:
-                  self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 10:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
-                  return self;
-                case 3:
-                  self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 11:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,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;
-                case 3:
-                  self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 12:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
-                  return self;
-                case 3:
-                  self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 13:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
-                  self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
-                  return self;
-                case 3:
-                  self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 14:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,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;
-                case 3:
-                  self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 15:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,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;
-                case 3:
-                  self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          case 16:
-            {
-              switch(sw1)
-                {
-                case 1:
-                  self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
-                  return self;
-                case 2:
-                  tmp=DataArrayDouble::New();
-                  tmp->useArray(&v1[0],false,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;
-                case 3:
-                  self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
-                  return self;
-                default:
-                  throw INTERP_KERNEL::Exception(msg);
-                }
-              break;
-            }
-          default:
-            throw INTERP_KERNEL::Exception(msg);
-          }
-        return self;
+        return DataArrayT__setitem__<double>(self,obj,value);
       }
 
       DataArrayDouble *__neg__() const throw(INTERP_KERNEL::Exception)
index 0cc93355867e8c0b47f4567ef65756a9464b1b4e..3a7197450f9ebae61240cf7477e66d7494ebd712 100644 (file)
@@ -770,130 +770,129 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         d[:]=2
         #
         e=DataArrayFloat(sz) ; e.fillWithValue(2)
-        self.assertTrue(d.isEqual(e,1e-14))
+        self.assertTrue(d.isEqual(e,1e-7))
         #
         a[:]=4 ; e.fillWithValue(4)
-        self.assertTrue(d.isEqual(e,1e-14))
+        self.assertTrue(d.isEqual(e,1e-7))
         pass
     
-class MEDCouplingNumPyTest2:
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test30(self):
         """Same as test10 with float32"""
         sz=20
-        a=array(0,dtype=float64)
+        a=array(0,dtype=float32)
         a.resize(sz,2)
         self.assertEqual(getrefcount(a),2)
         b=a.reshape(2*sz)
         self.assertEqual(getrefcount(a),3)
         self.assertEqual(getrefcount(b),2)
         b[:]=5
-        d=DataArrayDouble(b)
+        d=DataArrayFloat(b)
         #
-        e=DataArrayDouble(sz*2) ; e.fillWithValue(5)
-        self.assertTrue(d.isEqual(e,1e-14))
+        e=DataArrayFloat(sz*2) ; e.fillWithValue(5)
+        self.assertTrue(d.isEqual(e,1e-7))
         pass
     
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test31(self):
         """Same as test11 with float32"""
         sz=10
-        a=array(0,dtype=float64)
+        a=array(0,dtype=float32)
         a.resize(sz,2)
         b=a.reshape(2*sz)
         c=a.reshape(2,sz)
         b[:]=6
         b[7:17]=7
-        d=DataArrayDouble(b)
-        self.assertTrue(d.isEqual(DataArrayDouble([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6]),1e-14))
+        d=DataArrayFloat(b)
+        self.assertTrue(d.isEqual(DataArrayFloat([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6]),1e-7))
         #
-        a=zeros((10,2),dtype=float64)
+        a=zeros((10,2),dtype=float32)
         b=a.T
         c=b.view()
         a.shape=20
         a[3:]=10.
-        d=DataArrayDouble(a)
-        self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]),1e-14))
+        d=DataArrayFloat(a)
+        self.assertTrue(d.isEqual(DataArrayFloat([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]),1e-7))
         pass
     
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test32(self):
         """Same as test12 with float32"""
-        a=zeros(20,dtype=float64)
+        a=zeros(20,dtype=float32)
         b = a[::-1]
-        self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b is not contiguous in memory
+        self.assertRaises(InterpKernelException,DataArrayFloat.New,b) # b is not contiguous in memory
         pass
     
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test33(self):
         """Same as test13 with float32"""
-        a=arange(20,dtype=float64)
+        a=arange(20,dtype=float32)
         self.assertEqual(weakref.getweakrefcount(a),0)
-        d=DataArrayDouble(a)
+        d=DataArrayFloat(a)
         self.assertEqual(weakref.getweakrefcount(a),1)
         self.assertTrue(not a.flags["OWNDATA"])
-        self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+        self.assertTrue(d.isEqual(DataArrayFloat([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-7))
         self.assertEqual(len(d),20)
         a[:]=2 # modifying a and d because a and d share the same chunk of data
-        self.assertTrue(d.isUniform(2,1e-14))
+        self.assertTrue(d.isUniform(2,1e-7))
         del d # d is destroyed, a retrieves its ownership of its initial chunk of data
         ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
         import gc
         gc.collect()
         self.assertTrue(a.flags["OWNDATA"])
         a[:]=4 # a can be used has usual
-        self.assertTrue(DataArrayDouble(a).isUniform(4,1e-14))
+        self.assertTrue(DataArrayFloat(a).isUniform(4,1e-7))
         pass
     
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test34(self):
         """Same as test14 with float32"""
-        a=arange(20,dtype=float64)
-        d=DataArrayDouble(a) # d owns data of a
-        e=DataArrayDouble(a) # a not owned -> e only an access to chunk of a 
-        self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
-        self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+        a=arange(20,dtype=float32)
+        d=DataArrayFloat(a) # d owns data of a
+        e=DataArrayFloat(a) # a not owned -> e only an access to chunk of a 
+        self.assertTrue(d.isEqual(DataArrayFloat([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-7))
+        self.assertTrue(e.isEqual(DataArrayFloat([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-7))
         a[:]=6
-        self.assertTrue(d.isUniform(6,1e-14))
-        self.assertTrue(e.isUniform(6,1e-14))
+        self.assertTrue(d.isUniform(6,1e-7))
+        self.assertTrue(e.isUniform(6,1e-7))
         del a # a destroyed -> d no change because owned and e array is has no more data set
         ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
         import gc
         gc.collect()
-        self.assertTrue(d.isUniform(6,1e-14))
+        self.assertTrue(d.isUniform(6,1e-7))
         self.assertTrue(not e.isAllocated())
         pass
 
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test35(self):
         """Same as test15 with float32"""
-        a=array(0,dtype=float64) ; a.resize(10,2)
+        a=array(0,dtype=float32) ; a.resize(10,2)
         b=a.reshape(20)
         c=a.reshape(2,10)
-        d=DataArrayDouble(b) # d owns data of a
-        e=DataArrayDouble(b) # a not owned -> e only an access to chunk of a
-        f=DataArrayDouble(b) # a not owned -> e only an access to chunk of a
+        d=DataArrayFloat(b) # d owns data of a
+        e=DataArrayFloat(b) # a not owned -> e only an access to chunk of a
+        f=DataArrayFloat(b) # a not owned -> e only an access to chunk of a
         del d # d removed -> a ownes again data
         ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
         import gc
         gc.collect()
-        self.assertTrue(e.isUniform(0,1e-14))
+        self.assertTrue(e.isUniform(0,1e-7))
         e[:]=6
-        self.assertTrue(e.isUniform(6,1e-14))
-        self.assertTrue(f.isUniform(6,1e-14))
+        self.assertTrue(e.isUniform(6,1e-7))
+        self.assertTrue(f.isUniform(6,1e-7))
         self.assertEqual(b.tolist(),[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6])
         self.assertEqual(a.tolist(),[[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6]])
         b[:]=arange(20)
         del b # no impact on e and f because a is the base of a.
         ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
         gc.collect()
-        self.assertTrue(f.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
-        self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+        self.assertTrue(f.isEqual(DataArrayFloat([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-7))
+        self.assertTrue(e.isEqual(DataArrayFloat([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-7))
         del a # a destroyed, but as c has its base set to a, a exists -> e and f not allocated
         ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
         gc.collect()
-        self.assertTrue(f.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
-        self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+        self.assertTrue(f.isEqual(DataArrayFloat([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-7))
+        self.assertTrue(e.isEqual(DataArrayFloat([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-7))
         del c # c killed -> a killed -> e and d are put into not allocated state
         ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
         gc.collect()
@@ -904,40 +903,41 @@ class MEDCouplingNumPyTest2:
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test36(self):
         """Same as test16 with float32"""
-        a=arange(20,dtype=float64)
+        a=arange(20,dtype=float32)
         self.assertTrue(a.flags["OWNDATA"])
-        d=DataArrayDouble(a) # d owns data of a
+        d=DataArrayFloat(a) # d owns data of a
         self.assertTrue(not a.flags["OWNDATA"])
         d.pushBackSilent(20)# d pushBack so release of chunk of data -> a becomes owner of its data again
         self.assertTrue(a.flags["OWNDATA"])
-        self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),1e-14))
+        self.assertTrue(d.isEqual(DataArrayFloat([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),1e-7))
         self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
         pass
+class MEDCouplingNumPyTest2:
 
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test37(self):
         """Same as test20 with float32"""
         sz=20
-        a=array(0,dtype=float64)
+        a=array(0,dtype=float32)
         a.resize(sz/2,2)
         a[:]=4
         self.assertEqual(getrefcount(a),2)
-        d=DataArrayDouble(a)
+        d=DataArrayFloat(a)
         self.assertEqual(10,d.getNumberOfTuples())
         self.assertEqual(2,d.getNumberOfComponents())
         self.assertEqual(sz,d.getNbOfElems())
-        self.assertTrue(d.isEqual(DataArrayDouble([(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.)]),1e-14))
+        self.assertTrue(d.isEqual(DataArrayFloat([(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.)]),1e-7))
         a[:]=7
-        self.assertTrue(d.isEqual(DataArrayDouble([(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.)]),1e-14))
+        self.assertTrue(d.isEqual(DataArrayFloat([(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.)]),1e-7))
         #
         b=a.reshape((2,5,2))
-        self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b has not dimension in [0,1] !
+        self.assertRaises(InterpKernelException,DataArrayFloat.New,b) # b has not dimension in [0,1] !
         pass
 
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test38(self):
         """Same as test22 with float32"""
-        d=DataArrayDouble(10)
+        d=DataArrayFloat(10)
         d.iota()
         a=d.toNumPyArray()
         self.assertTrue(not a.flags["OWNDATA"])
@@ -959,7 +959,7 @@ class MEDCouplingNumPyTest2:
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test39(self):
         """Same as test23 with float32"""
-        d=DataArrayDouble(10)
+        d=DataArrayFloat(10)
         d.iota()
         a=d.toNumPyArray()
         b=d.toNumPyArray()
@@ -1003,7 +1003,7 @@ class MEDCouplingNumPyTest2:
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test40(self):
         """Same as test24 with float32"""
-        d=DataArrayDouble(10)
+        d=DataArrayFloat(10)
         d.iota()
         a=d.toNumPyArray()
         self.assertEqual(a.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])