else:
self.assertTrue(False)
pass
- try:
- da2=da[5:8,-2]
- except InterpKernelException as e:
- self.assertTrue(True)
- else:
- self.assertTrue(False)
- pass
+ self.assertTrue(da[5:8,-2].isEqualWithoutConsideringStr(DataArrayInt([23,26,29])))
da2=da[5:8,:-2]
self.assertEqual([22, 25, 28],da2.getValues())
try:
else:
self.assertTrue(False)
pass
- try:
- da2=da[5:8,-2]
- except InterpKernelException as e:
- self.assertTrue(True)
- else:
- self.assertTrue(False)
- pass
+ self.assertTrue(da[5:8,-2].isEqualWithoutConsideringStr(DataArrayDouble([23.,26.,29.]),1e-12))
da2=da[5:8,:-2]
self.assertEqual([22., 25., 28.],da2.getValues())
try:
def testSwigGetItem3(self):
da=DataArrayInt.New([4,5,6])
self.assertEqual(5,da[1])
- self.assertRaises(InterpKernelException,da.__getitem__,-1)
+ self.assertEqual(6,da[-1])
self.assertRaises(InterpKernelException,da.__getitem__,3)
da=DataArrayInt.New([4,5,6,7,8,9],2,3)
self.assertEqual(9,da[1,2])
da=DataArrayDouble.New([4.1,5.2,6.3])
self.assertAlmostEqual(5.2,da[1],12)
- self.assertRaises(InterpKernelException,da.__getitem__,-1)
+ self.assertAlmostEqual(6.3,da[-1],12)
self.assertRaises(InterpKernelException,da.__getitem__,3)
da=DataArrayDouble.New([4.12,5.12,6.12,7.12,8.12,9.12],2,3)
self.assertAlmostEqual(9.12,da[1,2],12)
self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,13,20,27])))
pass
+ def testSwigExtendedSlice1(self):
+ d=DataArrayInt([5,6,7])
+ self.assertTrue(d[2:].isEqual(DataArrayInt([7])))
+ self.assertTrue(d[3:].isEqual(DataArrayInt([])))
+ try:
+ d[4:]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ d=DataArrayInt([5,6,7,8])
+ self.assertEqual(d[-1],8)
+ self.assertEqual(d[-4],5)
+ try:
+ d[-5]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ self.assertTrue(d[2::-1].isEqual(DataArrayInt([7,6,5])))
+ self.assertTrue(d[0::-1].isEqual(DataArrayInt([5])))
+ self.assertTrue(d[-1::-1].isEqual(DataArrayInt([8,7,6,5])))
+ self.assertTrue(d[-3::-1].isEqual(DataArrayInt([6,5])))
+ self.assertTrue(d[-5::-1].isEqual(DataArrayInt([])))
+ try:
+ d[-6::-1]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ d=DataArrayInt([])
+ self.assertTrue(d[0:].isEqual(DataArrayInt([])))
+ #
+ d=DataArrayDouble([5,6,7])
+ self.assertTrue(d[2:].isEqual(DataArrayDouble([7]),1e-12))
+ self.assertTrue(d[3:].isEqual(DataArrayDouble([]),1e-12))
+ try:
+ d[4:]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ d=DataArrayDouble([5,6,7,8])
+ self.assertAlmostEqual(d[-1],8.,12)
+ self.assertAlmostEqual(d[-4],5.,12)
+ try:
+ d[-5]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ self.assertTrue(d[2::-1].isEqual(DataArrayDouble([7,6,5]),1e-12))
+ self.assertTrue(d[0::-1].isEqual(DataArrayDouble([5]),1e-12))
+ self.assertTrue(d[-1::-1].isEqual(DataArrayDouble([8,7,6,5]),1e-12))
+ self.assertTrue(d[-3::-1].isEqual(DataArrayDouble([6,5]),1e-12))
+ self.assertTrue(d[-5::-1].isEqual(DataArrayDouble([]),1e-12))
+ try:
+ d[-6::-1]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ d=DataArrayDouble([])
+ self.assertTrue(d[0:].isEqual(DataArrayDouble([]),1e-12))
+ pass
+
def setUp(self):
pass
pass
arrIndxIn->checkAllocated();
if(arrIndxIn->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("ExtractFromIndexedArrays2 (wrap) : number of components of last argument must be equal to one !");
- if(PySlice_GetIndices(sliC,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("ExtractFromIndexedArrays2 (wrap) : Invalid slice regarding nb of elements !");
+ GetIndicesOfSlice(sliC,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArrays2 (wrap) : Invalid slice regarding nb of elements !");
DataArrayInt *arrOut=0,*arrIndexOut=0;
MEDCouplingUMesh::ExtractFromIndexedArrays2(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
PyObject *ret=PyTuple_New(2);
#include "InterpKernelAutoPtr.hxx"
+/*!
+ * This method is an extention of PySlice_GetIndices but less
+ * open than PySlice_GetIndicesEx that accepts too many situations.
+ */
+void GetIndicesOfSlice(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
+{
+ int ret(PySlice_GetIndices(slice,length,start,stop,step));
+ if(ret==0)
+ return ;
+ if(*step>0 && *start==*stop && length==*start)
+ return ;
+ throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
+}
+
+/*!
+ * This method allows to retrieve slice info from \a slice.
+ */
+void GetIndicesOfSliceExplicitely(PySliceObject *slice, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
+{
+ int ret(PySlice_GetIndices(slice,std::numeric_limits<int>::max(),start,stop,step));
+ if(ret==0)
+ {
+ if(*start!=std::numeric_limits<int>::max() && *stop!=std::numeric_limits<int>::max())
+ return ;
+ std::ostringstream oss;
+ oss << msgInCaseOfFailure << " The input slice contains some unknowns that can't be determined in static method ! The input slice must be explicit here !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
+}
+
+int InterpreteNegativeInt(int val, int nbelem)
+{
+ if(val<0)
+ {
+ int newVal(nbelem+val);
+ if(newVal<0)
+ {
+ std::ostringstream oss; oss << "interpreteNegativeInt : request for negative int=" << val << " but number of elems is equal to " << nbelem << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return newVal;
+ }
+ else
+ return val;
+}
+
#ifdef WITH_NUMPY
#include <numpy/arrayobject.h>
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
- if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
- if(nbelem!=0 || strt!=0 || stp!=0)
- {
- std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elements is : " << nbelem;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ GetIndicesOfSlice(oC,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
p.first=strt;
p.second.first=stp;
p.second.second=step;
throw INTERP_KERNEL::Exception(msg);
}
+/*!
+ * Idem than convertObjToPossibleCpp2
+ */
+static void convertObjToPossibleCpp2WithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+{
+ convertObjToPossibleCpp2(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
+ if(sw==1)
+ {
+ iTyypp=InterpreteNegativeInt(iTyypp,nbelem);
+ }
+}
+
/*!
* if python int -> cpp int sw=1
* if python tuple[int] -> cpp vector<int> sw=2
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
- if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
- if(nbelem!=0 || strt!=0 || stp!=0)
- {
- std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elements is : " << nbelem;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ GetIndicesOfSlice(oC,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
p.first=strt;
p.second.first=stp;
p.second.second=step;
{
if(!PyTuple_Check(value))
{
- convertObjToPossibleCpp2(value,nbTuple,sw,it,vt,pt,dt);
+ convertObjToPossibleCpp2WithNegIntInterp(value,nbTuple,sw,it,vt,pt,dt);
return ;
}
else
throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
PyObject *ob0=PyTuple_GetItem(value,0);
int sw1,sw2;
- convertObjToPossibleCpp2(ob0,nbTuple,sw1,it,vt,pt,dt);
+ convertObjToPossibleCpp2WithNegIntInterp(ob0,nbTuple,sw1,it,vt,pt,dt);
PyObject *ob1=PyTuple_GetItem(value,1);
- convertObjToPossibleCpp2(ob1,nbCompo,sw2,ic,vc,pc,dc);
+ convertObjToPossibleCpp2WithNegIntInterp(ob1,nbCompo,sw2,ic,vc,pc,dc);
sw=4*sw2+sw1;
}
}
throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !");
int a,b;
DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !");
int a,b;
DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : the input slice contains some unknowns that can't be determined in static method !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice contains some unknowns that can't be determined in static method !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
}
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
const double *pt=self->getConstPointer();
int nbc=self->getNumberOfCompo();
- convertObjToPossibleCpp2(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
std::pair<int, std::pair<int,int> > slic;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
double *pt=self->getPointer();
- convertObjToPossibleCpp2(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
switch(sw2)
{
case 1:
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step);
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
const int *pt=self->getConstPointer();
int nbc=self->getNumberOfCompo();
- convertObjToPossibleCpp2(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
std::pair<int, std::pair<int,int> > slic;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
int *pt=self->getPointer();
- convertObjToPossibleCpp2(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
switch(sw2)
{
case 1:
std::vector<int> stdvecTyyppArr;
std::pair<int, std::pair<int,int> > sTyyppArr;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
- convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
switch(sw)
{
case 1:
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
int nbOfCompo=self->getNumberOfComponents();
int nbOfTuples=self->getNumberOfTuples();
- convertObjToPossibleCpp2(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
int sw2;
char vc; std::string sc; std::vector<std::string> vsc; DataArrayChar *dacc=0;
convertObjToPossibleCpp6(value,sw2,vc,sc,vsc,dacc);
class MEDCouplingNumPyTest(unittest.TestCase):
- @unittest.skipUnless(MEDCouplingHasNumPyBindings() and architecture()[0]=="64bit","requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test1(self):
sz=20
a=array(0,dtype=int32)
_param_per_ts=paramPerTs;
}
+int MEDFileParameterMultiTS::getNumberOfTS() const
+{
+ return (int) getIterations().size();
+}
+
std::vector< std::pair<int,int> > MEDFileParameterMultiTS::getIterations() const
{
std::vector< std::pair<int,int> > ret;
MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const;
MEDLOADER_EXPORT MEDFileParameter1TS *getTimeStepAtPos(int posId) const;
MEDLOADER_EXPORT void eraseTimeStepIds(const int *startIds, const int *endIds);
+ MEDLOADER_EXPORT int getNumberOfTS() const;
MEDLOADER_EXPORT std::vector< std::pair<int,int> > getIterations() const;
MEDLOADER_EXPORT std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const;
MEDLOADER_EXPORT void simpleRepr2(int bkOffset, std::ostream& oss) const;
{
if(PyInt_Check(obj))
{
- MEDFileMesh *ret=self->getMeshAtPos((int)PyInt_AS_LONG(obj));
+ MEDFileMesh *ret=self->getMeshAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfMeshes()));
if(ret)
ret->incrRef();
return ret;
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(elts);
- if(PySlice_GetIndices(oC,self->getNumberOfTS(),&strt,&stp,&step)==0)
- {
- self->eraseTimeStepIds2(strt,stp,step);
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !");
+ GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !");
+ self->eraseTimeStepIds2(strt,stp,step);
}
else
{
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(elt0);
- if(PySlice_GetIndices(oC,self->getNumberOfTS(),&strt,&stp,&step)==0)
- return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0);
- else
- throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !");
+ GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !");
+ return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0);
}
else
return convertMEDFileField1TS(self->getTimeStepAtPos(MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(self,elt0)),SWIG_POINTER_OWN | 0);
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(elts);
- if(PySlice_GetIndices(oC,self->getNumberOfFields(),&strt,&stp,&step)==0)
- self->destroyFieldsAtPos2(strt,stp,step);
- else
- throw INTERP_KERNEL::Exception("MEDFileFields.__delitem__ : error in input slice !");
+ GetIndicesOfSlice(oC,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !");
+ self->destroyFieldsAtPos2(strt,stp,step);
}
else
{
double getDoubleValue(int iteration, int order) const throw(INTERP_KERNEL::Exception);
int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfTS() const throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileParameterMultiTS()
{
if(elt0 && PyInt_Check(elt0))
{//fmts[3]
- int pos=PyInt_AS_LONG(elt0);
+ int pos=InterpreteNegativeInt(PyInt_AS_LONG(elt0),self->getNumberOfTS());
return pos;
}
else if(elt0 && PyTuple_Check(elt0))
{
if(PyInt_Check(obj))
{
- MEDFileParameterMultiTS *ret=self->getParamAtPos((int)PyInt_AS_LONG(obj));
+ MEDFileParameterMultiTS *ret=self->getParamAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfParams()));
if(ret)
ret->incrRef();
return ret;
{
if(elt0 && PyInt_Check(elt0))
{//fmts[3]
- return PyInt_AS_LONG(elt0);
+ return InterpreteNegativeInt(PyInt_AS_LONG(elt0),self->getNumberOfTS());
}
else if(elt0 && PyTuple_Check(elt0))
{
{
if(PyInt_Check(obj))
{
- return (int)PyInt_AS_LONG(obj);
+ return InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfFields());
}
else if(PyString_Check(obj))
{