def matdims(arr, oned_as='column'):
 shape = arr.shape
 if (shape == ()):
  return (1, 1)
 if (reduce(operator.mul, shape) == 0):
  return ((0,) * np.max([arr.ndim, 2]))
 if (len(shape) == 1):
  if (oned_as == 'column'):
   return (shape + (1,))
  elif (oned_as == 'row'):
   return ((1,) + shape)
  else:
   raise ValueError(('1D option "%s" is strange' % oned_as))
 return shape

def matdims ( arr , oned_as = 'column' ) : shape = arr . shape if ( shape == ( ) ) : return ( 1 , 1 ) if ( reduce ( operator . mul , shape ) == 0 ) : return ( ( 0 , ) * np . max ( [ arr . ndim , 2 ] ) ) if ( len ( shape ) == 1 ) : if ( oned_as == 'column' ) : return ( shape + ( 1 , ) ) elif ( oned_as == 'row' ) : return ( ( 1 , ) + shape ) else : raise ValueError ( ( '1D option "%s" is strange' % oned_as ) ) return shape
determine equivalent matlab dimensions for given array parameters arr : ndarray input array oned_as : {column .