std::ostringstream oss; oss << msg << " : end before begin !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+ if(end==begin)
+ return 0;
if(step<=0)
{
std::ostringstream oss; oss << msg << " : invalid step should be > 0 !";
{
if(!arr || !arrI)
throw INTERP_KERNEL::Exception("DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2 : presence of NULL ref of DataArrayInt in input !");
- DataArrayInt *ret=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(nbOfOldTuples,1);
int *pt=ret->getPointer();
std::fill(pt,pt+nbOfOldTuples,-1);
}
}
newNbOfTuples=newNb;
+ ret->incrRef();
return ret;
}
self.assertEqual(7,newNbTuple);
self.assertEqual(1,ret.getNumberOfComponents());
self.assertEqual(expected,ret.getValues());
+ self.assertRaises(InterpKernelException,DataArrayInt.BuildOld2NewArrayFromSurjectiveFormat2,9,a,b);
pass
def testDADIReverse1(self):
self.assertRaises(InterpKernelException,d.checkMonotonic,False)
pass
+ def testSwigDASetItemOnEmpty1(self):
+ d=DataArrayInt(0,1)
+ isThrow=False
+ try:
+ d[0:1000:2]=4
+ except InterpKernelException as e:
+ isThrow=True
+ pass
+ self.assertTrue(isThrow)
+ d[:]=4
+ d[::2]=5
+ #
+ d=DataArrayDouble(0,1)
+ isThrow=False
+ try:
+ d[0:1000:2]=4
+ except InterpKernelException as e:
+ isThrow=True
+ pass
+ self.assertTrue(isThrow)
+ d[:]=4
+ d[::2]=5
+ d=DataArrayInt([],0,1)
+ d2=DataArrayInt(0)
+ self.assertTrue(d2.isEqual(d))
+ d=DataArrayDouble([],0,1)
+ d2=DataArrayDouble(0)
+ self.assertTrue(d2.isEqual(d,1e-12))
+ pass
+
+ def testSwigDAITransformWithIndArr1(self):
+ arr=DataArrayInt([0,4,5,1])
+ d=DataArrayInt([7,8,9,10])
+ self.assertRaises(InterpKernelException,arr.transformWithIndArr,d)
+ pass
+
def setUp(self):
pass
pass
PyObject *o=PyList_GetItem(pyLi,i);
fillArrayWithPyListInt3(o,size2,ret);
}
+ if(size1==0)
+ size2=1;
}
else if(PyTuple_Check(pyLi))
{
PyObject *o=PyTuple_GetItem(pyLi,i);
fillArrayWithPyListInt3(o,size2,ret);
}
+ if(size1==0)
+ size2=1;
}
else
throw INTERP_KERNEL::Exception("fillArrayWithPyListInt2 : Unrecognized type ! Should be a tuple or a list !");
PyObject *o=PyList_GetItem(pyLi,i);
fillArrayWithPyListDbl3(o,size2,ret);
}
+ if(size1==0)
+ size2=1;
}
else if(PyTuple_Check(pyLi))
{
PyObject *o=PyTuple_GetItem(pyLi,i);
fillArrayWithPyListDbl3(o,size2,ret);
}
+ if(size1==0)
+ size2=1;
}
else
throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !");
}
if(PySlice_Check(value))
{
- Py_ssize_t strt,stp,step;
+ Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
- {
- std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elemnts is : " << nbelem;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ 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());
+ }
p.first=strt;
p.second.first=stp;
p.second.second=step;
}
if(PySlice_Check(value))
{
- Py_ssize_t strt,stp,step;
+ Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
- {
- std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elemnts is : " << nbelem;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ 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());
+ }
p.first=strt;
p.second.first=stp;
p.second.second=step;