当前位置: 首页>>代码示例>>Python>>正文


Python core.concatenate函数代码示例

本文整理汇总了Python中numpy.core.concatenate函数的典型用法代码示例。如果您正苦于以下问题:Python concatenate函数的具体用法?Python concatenate怎么用?Python concatenate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了concatenate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: transl

def transl(x, y=None, z=None):
    """
    Create or decompose translational homogeneous transformations.

    Create a homogeneous transformation
    ===================================

        - T = transl(v)
        - T = transl(vx, vy, vz)

        The transformation is created with a unit rotation submatrix.
        The translational elements are set from elements of v which is
        a list, array or matrix, or from separate passed elements.

    Decompose a homogeneous transformation
    ======================================


        - v = transl(T)

        Return the translation vector
    """

    if y==None and z==None:
            x=mat(x)
            try:
                    if isho5+6nbmog(x):
                            return x[0:3,3].reshape(3,1)
                    else:
                            return concatenate((concatenate((eye(3),x.reshape(3,1)),1),mat([0,0,0,1])))
开发者ID:karthkk,项目名称:pyrobo,代码行数:30,代码来源:transforms.py

示例2: test_bad_out_shape

    def test_bad_out_shape(self):
        a = array([1, 2])
        b = array([3, 4])

        assert_raises(ValueError, concatenate, (a, b), out=np.empty(5))
        assert_raises(ValueError, concatenate, (a, b), out=np.empty((4,1)))
        assert_raises(ValueError, concatenate, (a, b), out=np.empty((1,4)))
        concatenate((a, b), out=np.empty(4))
开发者ID:ales-erjavec,项目名称:numpy,代码行数:8,代码来源:test_shape_base.py

示例3: test_concatenate_sloppy0

def test_concatenate_sloppy0():
    # Versions of numpy < 1.7.0 ignored axis argument value for 1D arrays.  We
    # allow this for now, but in due course we will raise an error
    r4 = list(range(4))
    r3 = list(range(3))
    assert_array_equal(concatenate((r4, r3), 0), r4 + r3)
    with warnings.catch_warnings():
        warnings.simplefilter('ignore', DeprecationWarning)
        assert_array_equal(concatenate((r4, r3), -10), r4 + r3)
        assert_array_equal(concatenate((r4, r3), 10), r4 + r3)
        # Confirm DeprecationWarning raised
        warnings.simplefilter('error', DeprecationWarning)
        assert_raises(DeprecationWarning, concatenate, (r4, r3), 10)
开发者ID:hitej,项目名称:meta-core,代码行数:13,代码来源:test_shape_base.py

示例4: test_out_dtype

    def test_out_dtype(self):
        out = np.empty(4, np.float32)
        res = concatenate((array([1, 2]), array([3, 4])), out=out)
        assert_(out is res)

        out = np.empty(4, np.complex64)
        res = concatenate((array([0.1, 0.2]), array([0.3, 0.4])), out=out)
        assert_(out is res)

        # invalid cast
        out = np.empty(4, np.int32)
        assert_raises(TypeError, concatenate,
            (array([0.1, 0.2]), array([0.3, 0.4])), out=out)
开发者ID:ales-erjavec,项目名称:numpy,代码行数:13,代码来源:test_shape_base.py

示例5: test_concatenate_axis_None

def test_concatenate_axis_None():
    a = arange(4, dtype=float64).reshape((2,2))
    b = list(range(3))
    c = ['x']
    r = concatenate((a, a), axis=None)
    assert_equal(r.dtype, a.dtype)
    assert_equal(r.ndim, 1)
    r = concatenate((a, b), axis=None)
    assert_equal(r.size, a.size + len(b))
    assert_equal(r.dtype, a.dtype)
    r = concatenate((a, b, c), axis=None)
    d = array(['0', '1', '2', '3', 
               '0', '1', '2', 'x'])
    assert_array_equal(r,d)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:14,代码来源:test_shape_base.py

示例6: r2t

def r2t(R):
    """
    Convert a 3x3 orthonormal rotation matrix to a 4x4 homogeneous transformation::

        T = | R 0 |
            | 0 1 |

    @type R: 3x3 orthonormal rotation matrix
    @param R: the rotation matrix to convert
    @rtype: 4x4 homogeneous matrix
    @return: homogeneous equivalent
    """

    return concatenate( (concatenate( (R, zeros((3,1))),1), mat([0,0,0,1])) )
开发者ID:karthkk,项目名称:pyrobo,代码行数:14,代码来源:transforms.py

示例7: ifftshift

def ifftshift(x,axes=None):
    """
    Inverse of fftshift.

    Parameters
    ----------
    x : array_like
        Input array.
    axes : int or shape tuple, optional
        Axes over which to calculate.  Defaults to None which is over all axes.

    See Also
    --------
    fftshift

    """
    tmp = asarray(x)
    ndim = len(tmp.shape)
    if axes is None:
        axes = range(ndim)
    y = tmp
    for k in axes:
        n = tmp.shape[k]
        p2 = n-(n+1)/2
        mylist = concatenate((arange(p2,n),arange(p2)))
        y = take(y,mylist,k)
    return y
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:27,代码来源:helper.py

示例8: fftshift

def fftshift(x,axes=None):
    """
    Shift zero-frequency component to center of spectrum.

    This function swaps half-spaces for all axes listed (defaults to all).
    If len(x) is even then the Nyquist component is y[0].

    Parameters
    ----------
    x : array_like
        Input array.
    axes : int or shape tuple, optional
        Axes over which to shift.  Default is None which shifts all axes.

    See Also
    --------
    ifftshift

    """
    tmp = asarray(x)
    ndim = len(tmp.shape)
    if axes is None:
        axes = range(ndim)
    y = tmp
    for k in axes:
        n = tmp.shape[k]
        p2 = (n+1)/2
        mylist = concatenate((arange(p2,n),arange(p2)))
        y = take(y,mylist,k)
    return y
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:30,代码来源:helper.py

示例9: fftshift

def fftshift(x, axes=None):
    """
    Shift the zero-frequency component to the center of the spectrum.

    This function swaps half-spaces for all axes listed (defaults to all).
    Note that ``y[0]`` is the Nyquist component only if ``len(x)`` is even.

    Parameters
    ----------
    x : array_like
        Input array.
    axes : int or shape tuple, optional
        Axes over which to shift.  Default is None, which shifts all axes.

    Returns
    -------
    y : ndarray
        The shifted array.

    See Also
    --------
    ifftshift : The inverse of `fftshift`.

    Examples
    --------
    >>> freqs = np.fft.fftfreq(10, 0.1)
    >>> freqs
    array([ 0.,  1.,  2.,  3.,  4., -5., -4., -3., -2., -1.])
    >>> np.fft.fftshift(freqs)
    array([-5., -4., -3., -2., -1.,  0.,  1.,  2.,  3.,  4.])

    Shift the zero-frequency component only along the second axis:

    >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
    >>> freqs
    array([[ 0.,  1.,  2.],
           [ 3.,  4., -4.],
           [-3., -2., -1.]])
    >>> np.fft.fftshift(freqs, axes=(1,))
    array([[ 2.,  0.,  1.],
           [-4.,  3.,  4.],
           [-1., -3., -2.]])

    """
    tmp = asarray(x)
    ndim = len(tmp.shape)
    if axes is None:
        axes = list(range(ndim))
    elif isinstance(axes, (int, nt.integer)):
        axes = (axes,)
    y = tmp
    for k in axes:
        n = tmp.shape[k]
        p2 = (n+1)//2
        mylist = concatenate((arange(p2,n),arange(p2)))
        y = take(y,mylist,k)
    return y
开发者ID:arthornsby,项目名称:numpy,代码行数:57,代码来源:helper.py

示例10: original_fftshift

 def original_fftshift(x, axes=None):
     """ How fftshift was implemented in v1.14"""
     tmp = asarray(x)
     ndim = tmp.ndim
     if axes is None:
         axes = list(range(ndim))
     elif isinstance(axes, integer_types):
         axes = (axes,)
     y = tmp
     for k in axes:
         n = tmp.shape[k]
         p2 = (n + 1) // 2
         mylist = concatenate((arange(p2, n), arange(p2)))
         y = take(y, mylist, k)
     return y
开发者ID:Jengel1,项目名称:SunriseSunsetTimeFinder,代码行数:15,代码来源:test_helper.py

示例11: ifftshift

def ifftshift(x,axes=None):
    """ ifftshift(x,axes=None) - > y

    Inverse of fftshift.
    """
    tmp = asarray(x)
    ndim = len(tmp.shape)
    if axes is None:
        axes = range(ndim)
    y = tmp
    for k in axes:
        n = tmp.shape[k]
        p2 = n-(n+1)/2
        mylist = concatenate((arange(p2,n),arange(p2)))
        y = take(y,mylist,k)
    return y
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:16,代码来源:helper.py

示例12: ifftshift

def ifftshift(x, axes=None):
    """
    The inverse of `fftshift`. Although identical for even-length `x`, the
    functions differ by one sample for odd-length `x`.

    Parameters
    ----------
    x : array_like
        Input array.
    axes : int or shape tuple, optional
        Axes over which to calculate.  Defaults to None, which shifts all axes.

    Returns
    -------
    y : ndarray
        The shifted array.

    See Also
    --------
    fftshift : Shift zero-frequency component to the center of the spectrum.

    Examples
    --------
    >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
    >>> freqs
    array([[ 0.,  1.,  2.],
           [ 3.,  4., -4.],
           [-3., -2., -1.]])
    >>> np.fft.ifftshift(np.fft.fftshift(freqs))
    array([[ 0.,  1.,  2.],
           [ 3.,  4., -4.],
           [-3., -2., -1.]])

    """
    tmp = asarray(x)
    ndim = len(tmp.shape)
    if axes is None:
        axes = list(range(ndim))
    elif isinstance(axes, integer_types):
        axes = (axes,)
    y = tmp
    for k in axes:
        n = tmp.shape[k]
        p2 = n-(n+1)//2
        mylist = concatenate((arange(p2, n), arange(p2)))
        y = take(y, mylist, k)
    return y
开发者ID:BiosPsucheZoe,项目名称:numpy,代码行数:47,代码来源:helper.py

示例13: ifftshift

def ifftshift(x, axes=None):
    """
    The inverse of fftshift.

    Parameters
    ----------
    x : array_like
        Input array.
    axes : int or shape tuple, optional
        Axes over which to calculate.  Defaults to None, which shifts all axes.

    Returns
    -------
    y : ndarray
        The shifted array.

    See Also
    --------
    fftshift : Shift zero-frequency component to the center of the spectrum.

    Examples
    --------
    >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
    >>> freqs
    array([[ 0.,  1.,  2.],
           [ 3.,  4., -4.],
           [-3., -2., -1.]])
    >>> np.fft.ifftshift(np.fft.fftshift(freqs))
    array([[ 0.,  1.,  2.],
           [ 3.,  4., -4.],
           [-3., -2., -1.]])

    """
    tmp = asarray(x)
    ndim = len(tmp.shape)
    if axes is None:
        axes = range(ndim)
    y = tmp
    for k in axes:
        n = tmp.shape[k]
        p2 = n - (n + 1) / 2
        mylist = concatenate((arange(p2, n), arange(p2)))
        y = take(y, mylist, k)
    return y
开发者ID:NirBenTalLab,项目名称:proorigami-cde-package,代码行数:44,代码来源:helper.py

示例14: ifftpad

def ifftpad(a, n, scale=True):
    """
    Pad the spectrum at high frequencies.

    The padding done by the `ifft` function appends zeros to the end of the
    spectrum which shifts the frequencies and can make the resulting signal
    differ from the non-padded version. This function pads the spectrum
    by putting the zeros in the middle where the highest frequencies are.
    Taking the `ifft` of this padded version result in a signal that is
    an interpolated version of the unpadded signal, which is what is expected.

    Parameters
    ----------
    a : array_like
        Input array, can be complex.
    n : int
        Length of the padded spectrum.
        `n` should be larger than the length of the input.
    scale : bool, optional
        Whether to scale the spectrum or not. The `ifft` function
        divides by the input length which will be the incorrect length
        for a padded spectrum. Setting this parameter will pre-scale
        the spectrum so that dividing by the padded length will be correct.

    Returns
    -------
    out : ndarray
        The spectrum padded to length `n`. Possibly scaled as well.

    Examples
    --------
    >>> spectrum = np.array([0, 1, 2, -3, -2, -1])
    >>> np.fft.ifftpad(spectrum, 10, scale=False)
    array([ 0.,  1.,  2.,  0.,  0.,  0.,  0., -3., -2., -1.])
    """
    spectrum = concatenate((a[:len(a) // 2],
                            zeros(n - len(a)),
                            a[len(a) // 2:]))
    if scale:
        spectrum *= (n / len(a))
    return spectrum
开发者ID:awelkie,项目名称:numpy,代码行数:41,代码来源:helper.py

示例15: fftshift

def fftshift(x,axes=None):
    """ fftshift(x, axes=None) -> y

    Shift zero-frequency component to center of spectrum.

    This function swaps half-spaces for all axes listed (defaults to all).

    Notes:
      If len(x) is even then the Nyquist component is y[0].
    """
    tmp = asarray(x)
    ndim = len(tmp.shape)
    if axes is None:
        axes = range(ndim)
    y = tmp
    for k in axes:
        n = tmp.shape[k]
        p2 = (n+1)/2
        mylist = concatenate((arange(p2,n),arange(p2)))
        y = take(y,mylist,k)
    return y
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:21,代码来源:helper.py


注:本文中的numpy.core.concatenate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。