stream << varName << "->setName(\"" << getName() << "\");" << std::endl;
}
+/*!
+ * Method that gives a quick overvien of \a this for python.
+ */
+void DataArrayDouble::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
+{
+ static const std::size_t MAX_NB_OF_BYTE_IN_REPR=300;
+ stream << "DataArrayDouble C++ instance at " << this << ". ";
+ if(isAllocated())
+ {
+ int nbOfCompo=(int)_info_on_compo.size();
+ if(nbOfCompo>=1)
+ {
+ int nbOfTuples=getNumberOfTuples();
+ stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
+ const double *data=begin();
+ std::ostringstream oss2; oss2 << "[";
+ oss2.precision(17);
+ std::string oss2Str(oss2.str());
+ bool isFinished=true;
+ for(int i=0;i<nbOfTuples && isFinished;i++)
+ {
+ if(nbOfCompo>1)
+ {
+ oss2 << "(";
+ for(int j=0;j<nbOfCompo;j++,data++)
+ {
+ oss2 << *data;
+ if(j!=nbOfCompo-1) oss2 << ", ";
+ }
+ oss2 << ")";
+ }
+ else
+ oss2 << *data++;
+ if(i!=nbOfTuples-1) oss2 << ", ";
+ std::string oss3Str(oss2.str());
+ if(oss3Str.length()<MAX_NB_OF_BYTE_IN_REPR)
+ oss2Str=oss3Str;
+ else
+ isFinished=false;
+ }
+ stream << oss2Str;
+ if(!isFinished)
+ stream << "... ";
+ stream << "]";
+ }
+ else
+ stream << "Number of components : 0.";
+ }
+ else
+ stream << "*** No data allocated ****";
+}
+
/*!
* Equivalent to DataArrayDouble::isEqual except that if false the reason of
* mismatch is given.
stream << varName << "->setName(\"" << getName() << "\");" << std::endl;
}
+/*!
+ * Method that gives a quick overvien of \a this for python.
+ */
+void DataArrayInt::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
+{
+ static const std::size_t MAX_NB_OF_BYTE_IN_REPR=300;
+ stream << "DataArrayInt C++ instance at " << this << ". ";
+ if(isAllocated())
+ {
+ int nbOfCompo=(int)_info_on_compo.size();
+ if(nbOfCompo>=1)
+ {
+ int nbOfTuples=getNumberOfTuples();
+ stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
+ const int *data=begin();
+ std::ostringstream oss2; oss2 << "[";
+ std::string oss2Str(oss2.str());
+ bool isFinished=true;
+ for(int i=0;i<nbOfTuples && isFinished;i++)
+ {
+ if(nbOfCompo>1)
+ {
+ oss2 << "(";
+ for(int j=0;j<nbOfCompo;j++,data++)
+ {
+ oss2 << *data;
+ if(j!=nbOfCompo-1) oss2 << ", ";
+ }
+ oss2 << ")";
+ }
+ else
+ oss2 << *data++;
+ if(i!=nbOfTuples-1) oss2 << ", ";
+ std::string oss3Str(oss2.str());
+ if(oss3Str.length()<MAX_NB_OF_BYTE_IN_REPR)
+ oss2Str=oss3Str;
+ else
+ isFinished=false;
+ }
+ stream << oss2Str;
+ if(!isFinished)
+ stream << "... ";
+ stream << "]";
+ }
+ else
+ stream << "Number of components : 0.";
+ }
+ else
+ stream << "*** No data allocated ****";
+}
+
/*!
* Modifies \a this one-dimensional array so that each value \a v = \a indArrBg[ \a v ],
* i.e. a current value is used as in index to get a new value from \a indArrBg.
MEDCOUPLING_EXPORT virtual void reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT virtual void reprZipWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual void reprCppStream(const char *varName, std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0;
protected:
DataArray() { }
protected:
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd,
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const throw(INTERP_KERNEL::Exception);
private:
~DataArrayByte() { }
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const throw(INTERP_KERNEL::Exception);
private:
~DataArrayAsciiChar() { }
void DataArrayByte::reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
{
DataArray::reprWithoutNameStream(stream);
- _mem.repr(getNumberOfComponents(),stream);
+ if(_mem.reprHeader(getNumberOfComponents(),stream))
+ {
+ const char *data=begin();
+ int nbOfTuples=getNumberOfTuples();
+ int nbCompo=getNumberOfComponents();
+ for(int i=0;i<nbOfTuples;i++,data+=nbCompo)
+ {
+ stream << "Tuple #" << i << " : ";
+ std::copy(data,data+nbCompo,std::ostream_iterator<int>(stream," "));//it is not a bug int here not char because it is not ASCII here contrary to DataArrayAsciiChar
+ stream << "\n";
+ }
+ }
}
void DataArrayByte::reprZipWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
stream << varName << "->setName(\"" << getName() << "\");" << std::endl;
}
+/*!
+ * Method that gives a quick overvien of \a this for python.
+ */
+void DataArrayByte::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
+{
+ static const std::size_t MAX_NB_OF_BYTE_IN_REPR=300;
+ stream << "DataArrayByte C++ instance at " << this << ". ";
+ if(isAllocated())
+ {
+ int nbOfCompo=(int)_info_on_compo.size();
+ if(nbOfCompo>=1)
+ {
+ int nbOfTuples=getNumberOfTuples();
+ stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
+ const char *data=begin();
+ std::ostringstream oss2; oss2 << "[";
+ std::string oss2Str(oss2.str());
+ bool isFinished=true;
+ for(int i=0;i<nbOfTuples && isFinished;i++)
+ {
+ if(nbOfCompo>1)
+ {
+ oss2 << "(";
+ for(int j=0;j<nbOfCompo;j++,data++)
+ {
+ oss2 << (int)*data;
+ if(j!=nbOfCompo-1) oss2 << ", ";
+ }
+ oss2 << ")";
+ }
+ else
+ { oss2 << (int)*data; data++; }
+ if(i!=nbOfTuples-1) oss2 << ", ";
+ std::string oss3Str(oss2.str());
+ if(oss3Str.length()<MAX_NB_OF_BYTE_IN_REPR)
+ oss2Str=oss3Str;
+ else
+ isFinished=false;
+ }
+ stream << oss2Str;
+ if(!isFinished)
+ stream << "... ";
+ stream << "]";
+ }
+ else
+ stream << "Number of components : 0.";
+ }
+ else
+ stream << "*** No data allocated ****";
+}
+
bool DataArrayByte::isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
const DataArrayByte *otherC=dynamic_cast<const DataArrayByte *>(&other);
stream << varName << "->setName(\"" << getName() << "\");" << std::endl;
}
+/*!
+ * Method that gives a quick overvien of \a this for python.
+ */
+void DataArrayAsciiChar::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
+{
+ static const std::size_t MAX_NB_OF_BYTE_IN_REPR=300;
+ stream << "DataArrayAsciiChar C++ instance at " << this << ". ";
+ if(isAllocated())
+ {
+ int nbOfCompo=(int)_info_on_compo.size();
+ if(nbOfCompo>=1)
+ {
+ int nbOfTuples=getNumberOfTuples();
+ stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
+ const char *data=begin();
+ std::ostringstream oss2; oss2 << "[";
+ std::string oss2Str(oss2.str());
+ bool isFinished=true;
+ for(int i=0;i<nbOfTuples && isFinished;i++)
+ {
+ bool isAscii=true;
+ for(int j=0;j<nbOfCompo;j++)
+ if(data[j]<32) isAscii=false;
+ if(isAscii)
+ {
+ oss2 << "\'";
+ for(int j=0;j<nbOfCompo;j++,data++)
+ oss2 << *data;
+ oss2 << "\'";
+ }
+ else
+ {
+ oss2 << "(";
+ for(int j=0;j<nbOfCompo;j++,data++)
+ {
+ oss2 << (int)*data;
+ if(j!=nbOfCompo-1) oss2 << ", ";
+ }
+ oss2 << ")";
+ }
+ if(i!=nbOfTuples-1) oss2 << ", ";
+ std::string oss3Str(oss2.str());
+ if(oss3Str.length()<MAX_NB_OF_BYTE_IN_REPR)
+ oss2Str=oss3Str;
+ else
+ isFinished=false;
+ }
+ stream << oss2Str;
+ if(!isFinished)
+ stream << "... ";
+ stream << "]";
+ }
+ else
+ stream << "Number of components : 0.";
+ }
+ else
+ stream << "*** No data allocated ****";
+}
+
bool DataArrayAsciiChar::isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
const DataArrayAsciiChar *otherC=dynamic_cast<const DataArrayAsciiChar *>(&other);
self.assertTrue(m4.getBarycenterAndOwner().isEqual(DataArrayDouble([0.3333333333333333,0.3333333333333333,0.,0.3333333333333333,0.3333333333333333,0.,0.5,0.,0.,0.5,0.5,0.,0.,0.5,0.,0.3333333333333333,0.3333333333333333,2.,0.5,0.,1.,0.5,0.5,1.,0.,0.5,1.,0.5,0.5,0.],10,3),1e-13))
pass
+ def testSwigRepr1(self):
+ d=DataArrayDouble()
+ self.assertTrue(len(d.__repr__())<100)
+ d.alloc(1000,0) ; self.assertTrue(len(d.__repr__())<100)
+ for i in xrange(100):
+ d.alloc(i,1) ; d.iota(1.1234567890123456) ; d*=1e123
+ self.assertTrue(len(d.__repr__())<500)
+ pass
+ for i in xrange(50):
+ d.alloc(i,2) ; d.rearrange(1) ; d.iota(1.1234567890123456) ; d.rearrange(2) ; d*=1e123
+ self.assertTrue(len(d.__repr__())<500)
+ pass
+ d.alloc(4000,1) ; d.iota() ; self.assertTrue(len(d.__repr__())<500)
+ for i in xrange(2,4):
+ d.alloc(362880,1) ; d.iota() ; d.rearrange(i) ; self.assertTrue(len(d.__repr__())<500)
+ pass
+ d.alloc(0,9)
+ self.assertTrue(len(d.__repr__())<100)
+ #
+ d=DataArrayInt()
+ self.assertTrue(len(d.__repr__())<100)
+ d.alloc(1000,0) ; self.assertTrue(len(d.__repr__())<100)
+ for i in xrange(100):
+ d.alloc(i,1) ; d.iota(123456789)
+ self.assertTrue(len(d.__repr__())<500)
+ pass
+ for i in xrange(50):
+ d.alloc(i,2) ; d.rearrange(1) ; d.iota(123456789) ; d.rearrange(2)
+ self.assertTrue(len(d.__repr__())<500)
+ pass
+ d.alloc(4000,1) ; d.iota() ; self.assertTrue(len(d.__repr__())<500)
+ for i in xrange(2,10):
+ d.alloc(362880,1) ; d.iota() ; d.rearrange(i) ; self.assertTrue(len(d.__repr__())<500)
+ pass
+ d.alloc(0,9)
+ self.assertTrue(len(d.__repr__())<100)
+ #
+ d=DataArrayAsciiChar()
+ d.alloc(1000,0) ; self.assertTrue(len(d.__repr__())<100)
+ d.alloc(2,16) ; d[:]='1234567890ABCDEF'
+ self.assertTrue(len(d.__repr__())<500)
+ d.alloc(2000,16) ; d[:]='1234567890ABCDEF'
+ self.assertTrue(len(d.__repr__())<500)
+ d.alloc(0,16) ; d[:]='1234567890ABCDEF'
+ self.assertTrue(len(d.__repr__())<100)
+ #
+ d=DataArrayByte()
+ self.assertTrue(len(d.__repr__())<100)
+ d.alloc(1000,0) ; self.assertTrue(len(d.__repr__())<100)
+ d.alloc(0,16) ; self.assertTrue(len(d.__repr__())<100)
+ d.alloc(5,1) ; d.fillWithValue(127)
+ self.assertTrue(len(d.__repr__())<200)
+ d.alloc(1000,1) ; d.fillWithValue(127)
+ self.assertTrue(len(d.__repr__())<500)
+ d.alloc(1000,3) ; d.fillWithValue(127)
+ self.assertTrue(len(d.__repr__())<500)
+ pass
+
def setUp(self):
pass
pass
%extend ParaMEDMEM::DataArrayInt
{
+
+ std::string __repr__() const throw(INTERP_KERNEL::Exception)
+ {
+ std::ostringstream oss;
+ self->reprQuickOverview(oss);
+ return oss.str();
+ }
+
void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception)
{
int szArr,sw,iTypppArr;
%extend ParaMEDMEM::DataArrayChar
{
- int __len__() const throw(INTERP_KERNEL::Exception)
+ int __len__() const throw(INTERP_KERNEL::Exception)
{
if(self->isAllocated())
{
return ParaMEDMEM_DataArrayByte_New__SWIG_1(elt0,nbOfTuples,nbOfComp);
}
+ std::string __repr__() const throw(INTERP_KERNEL::Exception)
+ {
+ std::ostringstream oss;
+ self->reprQuickOverview(oss);
+ return oss.str();
+ }
+
int __int__() const throw(INTERP_KERNEL::Exception)
{
return (int) self->byteValue();
return ParaMEDMEM_DataArrayAsciiChar_New__SWIG_3(elt0,nbOfTuples,nbOfComp);
}
+ std::string __repr__() const throw(INTERP_KERNEL::Exception)
+ {
+ std::ostringstream oss;
+ self->reprQuickOverview(oss);
+ return oss.str();
+ }
+
DataArrayAsciiCharIterator *__iter__() throw(INTERP_KERNEL::Exception)
{
return self->iterator();
self->pushBackValsSilent(tmp,tmp+nbTuples);
}
+ std::string __repr__() const throw(INTERP_KERNEL::Exception)
+ {
+ std::ostringstream oss;
+ self->reprQuickOverview(oss);
+ return oss.str();
+ }
+
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
return self->repr();