本文整理汇总了Python中numpy.core.concatenate函数的典型用法代码示例。如果您正苦于以下问题:Python concatenate函数的具体用法?Python concatenate怎么用?Python concatenate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了concatenate函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_concatenate
def test_concatenate():
# Test concatenate function
# No arrays raise ValueError
assert_raises(ValueError, concatenate, ())
# Scalars cannot be concatenated
assert_raises(ValueError, concatenate, (0,))
assert_raises(ValueError, concatenate, (array(0),))
# One sequence returns unmodified (but as array)
r4 = list(range(4))
assert_array_equal(concatenate((r4,)), r4)
# Any sequence
assert_array_equal(concatenate((tuple(r4),)), r4)
assert_array_equal(concatenate((array(r4),)), r4)
# 1D default concatenation
r3 = list(range(3))
assert_array_equal(concatenate((r4, r3)), r4 + r3)
# Mixed sequence types
assert_array_equal(concatenate((tuple(r4), r3)), r4 + r3)
assert_array_equal(concatenate((array(r4), r3)), r4 + r3)
# Explicit axis specification
assert_array_equal(concatenate((r4, r3), 0), r4 + r3)
# Including negative
assert_array_equal(concatenate((r4, r3), -1), r4 + r3)
# 2D
a23 = array([[10, 11, 12], [13, 14, 15]])
a13 = array([[0, 1, 2]])
res = array([[10, 11, 12], [13, 14, 15], [0, 1, 2]])
assert_array_equal(concatenate((a23, a13)), res)
assert_array_equal(concatenate((a23, a13), 0), res)
assert_array_equal(concatenate((a23.T, a13.T), 1), res.T)
assert_array_equal(concatenate((a23.T, a13.T), -1), res.T)
# Arrays much match shape
assert_raises(ValueError, concatenate, (a23.T, a13.T), 0)
# 3D
res = arange(2 * 3 * 7).reshape((2, 3, 7))
a0 = res[..., :4]
a1 = res[..., 4:6]
a2 = res[..., 6:]
assert_array_equal(concatenate((a0, a1, a2), 2), res)
assert_array_equal(concatenate((a0, a1, a2), -1), res)
assert_array_equal(concatenate((a0.T, a1.T, a2.T), 0), res.T)
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:41,代码来源:test_shape_base.py
示例17: concatenate
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])))
except AttributeError:
n=len(x)
r = [[],[],[]]
for i in range(n):
r = concatenate((r,x[i][0:3,3]),1)
return r
elif y!=None and z!=None:
return concatenate((concatenate((eye(3),mat([x,y,z]).T),1),mat([0,0,0,1])))
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
开发者ID:karthkk,项目名称:pyrobo,代码行数:30,代码来源:transforms.py
注:本文中的numpy.core.concatenate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论