예제 #1
0
def arange(start, stop=None, step=1, dtype=None):
    """arange([start,] stop[, step=1])
    
    Return evenly spaced values within a given interval.
    
    Values are generated within the half-open interval ``[start, stop)``
    (in value words, the interval including `start` but excluding `stop`).
    
    Parameters
    ----------
    start : number, optional
        Start of interval.  The interval includes this value.  The default
        start value is 0.
    stop : number
        End of interval.  The interval does not include this value.
    step : number, optional
        Spacing between values.  For any output `out`, this is the distance
        between two adjacent values, ``out[i+1] - out[i]``.  The default
        step size is 1.  If `step` is specified, `start` must also be given.
        
    Examples:
    
    arange(5)
    arange(1, 5, 0.5)
    """
    if stop is None:
        # Only one number given, which is the 'stop'
        stop = start
        start = 0
    if dtype is None:
        return ndarray(NDMatrix.arange(start, stop, step))
    else:
        return ndarray(NDMatrix.arange(start, stop, step, dtype))
예제 #2
0
파일: ndarray.py 프로젝트: ATNF/cs-studio
def arange(start, stop=None, step=1, dtype=None):
    """arange([start,] stop[, step=1])
    
    Return evenly spaced values within a given interval.
    
    Values are generated within the half-open interval ``[start, stop)``
    (in value words, the interval including `start` but excluding `stop`).
    
    Parameters
    ----------
    start : number, optional
        Start of interval.  The interval includes this value.  The default
        start value is 0.
    stop : number
        End of interval.  The interval does not include this value.
    step : number, optional
        Spacing between values.  For any output `out`, this is the distance
        between two adjacent values, ``out[i+1] - out[i]``.  The default
        step size is 1.  If `step` is specified, `start` must also be given.
        
    Examples:
    
    arange(5)
    arange(1, 5, 0.5)
    """
    if stop is None:
        # Only one number given, which is the 'stop'
        stop = start
        start = 0
    if dtype is None:
        return ndarray(NDMatrix.arange(start, stop, step))
    else:
        return ndarray(NDMatrix.arange(start, stop, step, dtype))
예제 #3
0
def dot(a, b):
    """dot(a, b):
       Determine matrix 'dot' product of arrays a and b
    """
    result = ndarray(NDMatrix.dot(a.nda, b.nda))
    if result.ndim == 1 and len(result) == 1:
        return result[0]
    return result
예제 #4
0
def linspace(start, stop, num=50, dtype=float):
    """linspace(start, stop, num=50, dtype=float)
    
    Return evenly spaced values from start to stop, including stop.
    Example:
    linspace(2, 10, 5)
    """
    return ndarray(NDMatrix.linspace(start, stop, num, dtype))
예제 #5
0
def zeros(shape, dtype=float):
    """zeros(shape, dtype=float)
    
    Create array of zeros, example:
    
    zeros( (2, 3) )
    """
    return ndarray(NDMatrix.zeros(dtype, __toNDShape__(shape)))
예제 #6
0
def ones(shape, dtype=float):
    """ones(shape, dtype=float)
    
    Create array of ones, example:
    
    ones( (2, 3) )
    """
    return ndarray(NDMatrix.ones(dtype, __toNDShape__(shape)))
예제 #7
0
파일: ndarray.py 프로젝트: ATNF/cs-studio
def dot(a, b):
    """dot(a, b):
       Determine matrix 'dot' product of arrays a and b
    """
    result = ndarray(NDMatrix.dot(a.nda, b.nda))
    if result.ndim == 1 and len(result) == 1:
        return result[0]
    return result
예제 #8
0
파일: ndarray.py 프로젝트: ATNF/cs-studio
def linspace(start, stop, num=50, dtype=float):
    """linspace(start, stop, num=50, dtype=float)
    
    Return evenly spaced values from start to stop, including stop.
    Example:
    linspace(2, 10, 5)
    """
    return ndarray(NDMatrix.linspace(start, stop, num, dtype))
예제 #9
0
파일: ndarray.py 프로젝트: ATNF/cs-studio
def ones(shape, dtype=float):
    """ones(shape, dtype=float)
    
    Create array of ones, example:
    
    ones( (2, 3) )
    """
    return ndarray(NDMatrix.ones(dtype, __toNDShape__(shape)))
예제 #10
0
파일: ndarray.py 프로젝트: ATNF/cs-studio
def zeros(shape, dtype=float):
    """zeros(shape, dtype=float)
    
    Create array of zeros, example:
    
    zeros( (2, 3) )
    """
    return ndarray(NDMatrix.zeros(dtype, __toNDShape__(shape)))
예제 #11
0
def transpose(a, axes=None):
    """transpose(a, axes=None):
       Permute the axes of an array.
       By default, they are reversed.
       In a 2D array this would swap 'rows' and 'columns'
    """
    if axes is None:
        return a.transpose()
    return ndarray(NDMatrix.transpose(a.nda, axes))
예제 #12
0
def reshape(a, shape):
    """reshape(array, shape):
    Create array view with new shape
    
    Example:
    reshape(arange(6), (3, 2))
    results in array([ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ] ])
    """
    return ndarray(NDMatrix.reshape(self.nda, __toNDShape__(shape)))
예제 #13
0
파일: ndarray.py 프로젝트: ATNF/cs-studio
def transpose(a, axes=None):
    """transpose(a, axes=None):
       Permute the axes of an array.
       By default, they are reversed.
       In a 2D array this would swap 'rows' and 'columns'
    """
    if axes is None:
        return a.transpose()
    return ndarray(NDMatrix.transpose(a.nda, axes))
예제 #14
0
파일: ndarray.py 프로젝트: ATNF/cs-studio
def reshape(a, shape):
    """reshape(array, shape):
    Create array view with new shape
    
    Example:
    reshape(arange(6), (3, 2))
    results in array([ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ] ])
    """
    return ndarray(NDMatrix.reshape(self.nda, __toNDShape__(shape)))
예제 #15
0
 def transpose(self):
     """Compute transposed array, i.e. swap 'rows' and 'columns'"""
     return ndarray(NDMatrix.transpose(self.nda))
예제 #16
0
파일: ndarray.py 프로젝트: ATNF/cs-studio
 def transpose(self):
     """Compute transposed array, i.e. swap 'rows' and 'columns'"""
     return ndarray(NDMatrix.transpose(self.nda))