Evaluating strin composed of multiple parts?
Maurice van de Rijzen
maurice at akst.tn.tudelft.nl
Fri Sep 13 14:48:14 CEST 2002
Dear all,
I'm using numpy.
In numpy one can take a part of a multi array just as in matlab.
partArray=totalArray[1:10,1;10,:,:,:
Now I've encounterd the following problem.
I'm using the followoing code:
class SubDataMatrix_5D:
def SetInput(self,DataInput):
self.DataInput=DataInput
def SetDimensions(self,dim1,dim2,dim3,dim4,dim5):
self.Dim1=dim1
self.Dim2=dim2
self.Dim3=dim3
self.Dim4=dim4
self.Dim5=dim5
def CreateSubMatrix(self):
self.Sub=self.DataInput[eval(self.Dim1),eval...
(self.Dim2),eval(self.Dim3),eval(self.Dim4),...
eval(self.Dim5)]
def GetOutput(self):
return self.SubMatrix
temp2=SubDataMatrix_5D()
temp2.SetInput(temp.GetOutput())
temp2.SetDimensions("1:10","1:10","1:10","1:2","1:2")
temp2.CreateSubMatrix()
Doing this gives the following error:
self.SubMatrix=self.DataInput[eval(self.Dim1),eval(self.Dim2),eval(self.Dim3
),eval(self.Dim4),eval(self.Dim5)]
File "<string>", line 1
1:10
^
I know there goed something wrong with the strings but I have no clue of
how to solve it.
Preferrebly I would like to set the dimensions as follows:
temp2.SetDimensions(1:10,1:10,1:10,1:2,1:2)
Can someone please help me?
Maurice
More information about the Python-list
mailing list