Your IP : 216.73.216.213
�
��]c @` s� d d l m Z m Z m Z d d d d d d d g Z d d
l m Z d d l m Z m Z m
Z
d d l m Z d
� Z
d � Z d � Z d � Z d � Z d d � Z d e f d � � YZ d � Z d S( i ( t divisiont absolute_importt print_functiont
atleast_1dt
atleast_2dt
atleast_3dt blockt hstackt stackt vstacki ( t numeric( t arrayt
asanyarrayt newaxis( t normalize_axis_indexc G` sy g } xN | D]F } t | � } | j d k r@ | j d � } n | } | j | � q
Wt | � d k rq | d S| Sd S( s%
Convert inputs to arrays with at least one dimension.
Scalar inputs are converted to 1-dimensional arrays, whilst
higher-dimensional inputs are preserved.
Parameters
----------
arys1, arys2, ... : array_like
One or more input arrays.
Returns
-------
ret : ndarray
An array, or list of arrays, each with ``a.ndim >= 1``.
Copies are made only if necessary.
See Also
--------
atleast_2d, atleast_3d
Examples
--------
>>> np.atleast_1d(1.0)
array([ 1.])
>>> x = np.arange(9.0).reshape(3,3)
>>> np.atleast_1d(x)
array([[ 0., 1., 2.],
[ 3., 4., 5.],
[ 6., 7., 8.]])
>>> np.atleast_1d(x) is x
True
>>> np.atleast_1d(1, [3, 4])
[array([1]), array([3, 4])]
i i N( R t ndimt reshapet appendt len( t aryst rest aryt result( ( sH /opt/alt/python27/lib64/python2.7/site-packages/numpy/core/shape_base.pyR s '
c G` s� g } xy | D]q } t | � } | j d k rC | j d d � } n. | j d k rk | t d d � f } n | } | j | � q
Wt | � d k r� | d S| Sd S( s`
View inputs as arrays with at least two dimensions.
Parameters
----------
arys1, arys2, ... : array_like
One or more array-like sequences. Non-array inputs are converted
to arrays. Arrays that already have two or more dimensions are
preserved.
Returns
-------
res, res2, ... : ndarray
An array, or list of arrays, each with ``a.ndim >= 2``.
Copies are avoided where possible, and views with two or more
dimensions are returned.
See Also
--------
atleast_1d, atleast_3d
Examples
--------
>>> np.atleast_2d(3.0)
array([[ 3.]])
>>> x = np.arange(3.0)
>>> np.atleast_2d(x)
array([[ 0., 1., 2.]])
>>> np.atleast_2d(x).base is x
True
>>> np.atleast_2d(1, [1, 2], [[1, 2]])
[array([[1]]), array([[1, 2]]), array([[1, 2]])]
i i N( R R R R
R R ( R R R R ( ( sH /opt/alt/python27/lib64/python2.7/site-packages/numpy/core/shape_base.pyR ? s %
c G` s� g } x� | D]� } t | � } | j d k rF | j d d d � } nb | j d k rq | t d d � t f } n7 | j d k r� | d d � d d � t f } n | } | j | � q
Wt | � d k r� | d S| Sd S( s�
View inputs as arrays with at least three dimensions.
Parameters
----------
arys1, arys2, ... : array_like
One or more array-like sequences. Non-array inputs are converted to
arrays. Arrays that already have three or more dimensions are
preserved.
Returns
-------
res1, res2, ... : ndarray
An array, or list of arrays, each with ``a.ndim >= 3``. Copies are
avoided where possible, and views with three or more dimensions are
returned. For example, a 1-D array of shape ``(N,)`` becomes a view
of shape ``(1, N, 1)``, and a 2-D array of shape ``(M, N)`` becomes a
view of shape ``(M, N, 1)``.
See Also
--------
atleast_1d, atleast_2d
Examples
--------
>>> np.atleast_3d(3.0)
array([[[ 3.]]])
>>> x = np.arange(3.0)
>>> np.atleast_3d(x).shape
(1, 3, 1)
>>> x = np.arange(12.0).reshape(4,3)
>>> np.atleast_3d(x).shape
(4, 3, 1)
>>> np.atleast_3d(x).base is x.base # x is a reshape, so not base itself
True
>>> for arr in np.atleast_3d([1, 2], [[1, 2]], [[[1, 2]]]):
... print(arr, arr.shape)
...
[[[1]
[2]]] (1, 2, 1)
[[[1]
[2]]] (1, 2, 1)
[[[1 2]]] (1, 1, 2)
i i Ni ( R R R R
R R ( R R R R ( ( sH /opt/alt/python27/lib64/python2.7/site-packages/numpy/core/shape_base.pyR s s 1
"c C` s) t j g | D] } t | � ^ q
d � S( s
Stack arrays in sequence vertically (row wise).
Take a sequence of arrays and stack them vertically to make a single
array. Rebuild arrays divided by `vsplit`.
This function continues to be supported for backward compatibility, but
you should prefer ``np.concatenate`` or ``np.stack``. The ``np.stack``
function was added in NumPy 1.10.
Parameters
----------
tup : sequence of ndarrays
Tuple containing arrays to be stacked. The arrays must have the same
shape along all but the first axis.
Returns
-------
stacked : ndarray
The array formed by stacking the given arrays.
See Also
--------
stack : Join a sequence of arrays along a new axis.
hstack : Stack arrays in sequence horizontally (column wise).
dstack : Stack arrays in sequence depth wise (along third dimension).
concatenate : Join a sequence of arrays along an existing axis.
vsplit : Split array into a list of multiple sub-arrays vertically.
block : Assemble arrays from blocks.
Notes
-----
Equivalent to ``np.concatenate(tup, axis=0)`` if `tup` contains arrays that
are at least 2-dimensional.
Examples
--------
>>> a = np.array([1, 2, 3])
>>> b = np.array([2, 3, 4])
>>> np.vstack((a,b))
array([[1, 2, 3],
[2, 3, 4]])
>>> a = np.array([[1], [2], [3]])
>>> b = np.array([[2], [3], [4]])
>>> np.vstack((a,b))
array([[1],
[2],
[3],
[2],
[3],
[4]])
i ( t _nxt concatenateR ( t tupt _m( ( sH /opt/alt/python27/lib64/python2.7/site-packages/numpy/core/shape_base.pyR � s 7c C` s\ g | D] } t | � ^ q } | rH | d j d k rH t j | d � St j | d � Sd S( s�
Stack arrays in sequence horizontally (column wise).
Take a sequence of arrays and stack them horizontally to make
a single array. Rebuild arrays divided by `hsplit`.
This function continues to be supported for backward compatibility, but
you should prefer ``np.concatenate`` or ``np.stack``. The ``np.stack``
function was added in NumPy 1.10.
Parameters
----------
tup : sequence of ndarrays
All arrays must have the same shape along all but the second axis.
Returns
-------
stacked : ndarray
The array formed by stacking the given arrays.
See Also
--------
stack : Join a sequence of arrays along a new axis.
vstack : Stack arrays in sequence vertically (row wise).
dstack : Stack arrays in sequence depth wise (along third axis).
concatenate : Join a sequence of arrays along an existing axis.
hsplit : Split array along second axis.
block : Assemble arrays from blocks.
Notes
-----
Equivalent to ``np.concatenate(tup, axis=1)`` if `tup` contains arrays that
are at least 2-dimensional.
Examples
--------
>>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.hstack((a,b))
array([1, 2, 3, 2, 3, 4])
>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[2],[3],[4]])
>>> np.hstack((a,b))
array([[1, 2],
[2, 3],
[3, 4]])
i i N( R R R R ( R R t arrs( ( sH /opt/alt/python27/lib64/python2.7/site-packages/numpy/core/shape_base.pyR � s 1c C` s� g | D] } t | � ^ q } | s4 t d � � n t d � | D� � } t | � d k rk t d � � n | d j d } t | | � } t d � f | t j f } g | D] } | | ^ q� } t j
| d | �S( s'
Join a sequence of arrays along a new axis.
The `axis` parameter specifies the index of the new axis in the dimensions
of the result. For example, if ``axis=0`` it will be the first dimension
and if ``axis=-1`` it will be the last dimension.
.. versionadded:: 1.10.0
Parameters
----------
arrays : sequence of array_like
Each array must have the same shape.
axis : int, optional
The axis in the result array along which the input arrays are stacked.
Returns
-------
stacked : ndarray
The stacked array has one more dimension than the input arrays.
See Also
--------
concatenate : Join a sequence of arrays along an existing axis.
split : Split array into a list of multiple sub-arrays of equal size.
block : Assemble arrays from blocks.
Examples
--------
>>> arrays = [np.random.randn(3, 4) for _ in range(10)]
>>> np.stack(arrays, axis=0).shape
(10, 3, 4)
>>> np.stack(arrays, axis=1).shape
(3, 10, 4)
>>> np.stack(arrays, axis=2).shape
(3, 4, 10)
>>> a = np.array([1, 2, 3])
>>> b = np.array([2, 3, 4])
>>> np.stack((a, b))
array([[1, 2, 3],
[2, 3, 4]])
>>> np.stack((a, b), axis=-1)
array([[1, 2],
[2, 3],
[3, 4]])
s need at least one array to stackc s` s | ] } | j Vq d S( N( t shape( t .0t arr( ( sH /opt/alt/python27/lib64/python2.7/site-packages/numpy/core/shape_base.pys <genexpr>` s i s) all input arrays must have the same shapei t axisN( R t
ValueErrort setR R R t slicet NoneR R
R ( t arraysR R t shapest result_ndimt slt expanded_arrays( ( sH /opt/alt/python27/lib64/python2.7/site-packages/numpy/core/shape_base.pyR ( s 4t _Recurserc B` s>