def extendArr(inArray, newSize):
 if (type(inArray) in [tuple, list]):
  inArray = numpy.asarray(inArray)
 newArr = numpy.zeros(newSize, inArray.dtype)
 indString = ''
 for thisDim in inArray.shape:
  indString += (('0:' + str(thisDim)) + ',')
 indString = indString[0:(-1)]
 exec (('newArr[' + indString) + '] = inArray')
 return newArr

def extendArr ( inArray , newSize ) : if ( type ( inArray ) in [ tuple , list ] ) : inArray = numpy . asarray ( inArray ) newArr = numpy . zeros ( newSize , inArray . dtype ) indString = '' for thisDim in inArray . shape : indString += ( ( '0:' + str ( thisDim ) ) + ',' ) indString = indString [ 0 : ( - 1 ) ] exec ( ( 'newArr[' + indString ) + '] = inArray' ) return newArr
takes a numpy array and returns it padded with zeros to the necessary size .