Hackfut Security File Manager
Current Path:
/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
numpy
/
lib
/
📁
..
📄
__init__.py
(1.16 KB)
📄
__init__.pyc
(1.29 KB)
📄
__init__.pyo
(1.29 KB)
📄
_datasource.py
(20.77 KB)
📄
_datasource.pyc
(21.32 KB)
📄
_datasource.pyo
(21.32 KB)
📄
_iotools.py
(31.31 KB)
📄
_iotools.pyc
(29.52 KB)
📄
_iotools.pyo
(29.52 KB)
📄
_version.py
(4.75 KB)
📄
_version.pyc
(5.65 KB)
📄
_version.pyo
(5.65 KB)
📄
arraypad.py
(50.86 KB)
📄
arraypad.pyc
(48.4 KB)
📄
arraypad.pyo
(48.4 KB)
📄
arraysetops.py
(13.49 KB)
📄
arraysetops.pyc
(13.37 KB)
📄
arraysetops.pyo
(13.37 KB)
📄
arrayterator.py
(7.03 KB)
📄
arrayterator.pyc
(7.68 KB)
📄
arrayterator.pyo
(7.68 KB)
📄
financial.py
(23.28 KB)
📄
financial.pyc
(24.2 KB)
📄
financial.pyo
(24.2 KB)
📄
format.py
(27.57 KB)
📄
format.pyc
(25.03 KB)
📄
format.pyo
(25.03 KB)
📄
function_base.py
(146.99 KB)
📄
function_base.pyc
(133.09 KB)
📄
function_base.pyo
(133.09 KB)
📄
index_tricks.py
(25.59 KB)
📄
index_tricks.pyc
(26.72 KB)
📄
index_tricks.pyo
(26.72 KB)
📄
info.py
(6.35 KB)
📄
info.pyc
(6.6 KB)
📄
info.pyo
(6.6 KB)
📄
nanfunctions.py
(45.4 KB)
📄
nanfunctions.pyc
(44.28 KB)
📄
nanfunctions.pyo
(44.28 KB)
📄
npyio.py
(69.74 KB)
📄
npyio.pyc
(57.01 KB)
📄
npyio.pyo
(57.01 KB)
📄
polynomial.py
(37.12 KB)
📄
polynomial.pyc
(39.51 KB)
📄
polynomial.pyo
(39.51 KB)
📄
recfunctions.py
(34.19 KB)
📄
recfunctions.pyc
(30.43 KB)
📄
recfunctions.pyo
(30.43 KB)
📄
scimath.py
(13.75 KB)
📄
scimath.pyc
(15.79 KB)
📄
scimath.pyo
(15.79 KB)
📄
setup.py
(379 B)
📄
setup.pyc
(755 B)
📄
setup.pyo
(755 B)
📄
shape_base.py
(24.97 KB)
📄
shape_base.pyc
(26.44 KB)
📄
shape_base.pyo
(26.44 KB)
📄
stride_tricks.py
(6.67 KB)
📄
stride_tricks.pyc
(6.93 KB)
📄
stride_tricks.pyo
(6.93 KB)
📁
tests
📄
twodim_base.py
(26.27 KB)
📄
twodim_base.pyc
(29.16 KB)
📄
twodim_base.pyo
(29.16 KB)
📄
type_check.py
(15.43 KB)
📄
type_check.pyc
(16.89 KB)
📄
type_check.pyo
(16.89 KB)
📄
ufunclike.py
(4.73 KB)
📄
ufunclike.pyc
(5.51 KB)
📄
ufunclike.pyo
(5.51 KB)
📄
user_array.py
(7.81 KB)
📄
user_array.pyc
(16.28 KB)
📄
user_array.pyo
(16.28 KB)
📄
utils.py
(34.18 KB)
📄
utils.pyc
(30.22 KB)
📄
utils.pyo
(30.22 KB)
Editing: stride_tricks.py
""" Utilities that manipulate strides to achieve desirable effects. An explanation of strides can be found in the "ndarray.rst" file in the NumPy reference guide. """ from __future__ import division, absolute_import, print_function import numpy as np __all__ = ['broadcast_to', 'broadcast_arrays'] class DummyArray(object): """Dummy object that just exists to hang __array_interface__ dictionaries and possibly keep alive a reference to a base array. """ def __init__(self, interface, base=None): self.__array_interface__ = interface self.base = base def _maybe_view_as_subclass(original_array, new_array): if type(original_array) is not type(new_array): # if input was an ndarray subclass and subclasses were OK, # then view the result as that subclass. new_array = new_array.view(type=type(original_array)) # Since we have done something akin to a view from original_array, we # should let the subclass finalize (if it has it implemented, i.e., is # not None). if new_array.__array_finalize__: new_array.__array_finalize__(original_array) return new_array def as_strided(x, shape=None, strides=None, subok=False): """ Make an ndarray from the given array with the given shape and strides. """ # first convert input to array, possibly keeping subclass x = np.array(x, copy=False, subok=subok) interface = dict(x.__array_interface__) if shape is not None: interface['shape'] = tuple(shape) if strides is not None: interface['strides'] = tuple(strides) array = np.asarray(DummyArray(interface, base=x)) if array.dtype.fields is None and x.dtype.fields is not None: # This should only happen if x.dtype is [('', 'Vx')] array.dtype = x.dtype return _maybe_view_as_subclass(x, array) def _broadcast_to(array, shape, subok, readonly): shape = tuple(shape) if np.iterable(shape) else (shape,) array = np.array(array, copy=False, subok=subok) if not shape and array.shape: raise ValueError('cannot broadcast a non-scalar to a scalar array') if any(size < 0 for size in shape): raise ValueError('all elements of broadcast shape must be non-' 'negative') needs_writeable = not readonly and array.flags.writeable extras = ['reduce_ok'] if needs_writeable else [] op_flag = 'readwrite' if needs_writeable else 'readonly' broadcast = np.nditer( (array,), flags=['multi_index', 'refs_ok', 'zerosize_ok'] + extras, op_flags=[op_flag], itershape=shape, order='C').itviews[0] result = _maybe_view_as_subclass(array, broadcast) if needs_writeable and not result.flags.writeable: result.flags.writeable = True return result def broadcast_to(array, shape, subok=False): """Broadcast an array to a new shape. Parameters ---------- array : array_like The array to broadcast. shape : tuple The shape of the desired array. subok : bool, optional If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default). Returns ------- broadcast : array A readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. Raises ------ ValueError If the array is not compatible with the new shape according to NumPy's broadcasting rules. Notes ----- .. versionadded:: 1.10.0 Examples -------- >>> x = np.array([1, 2, 3]) >>> np.broadcast_to(x, (3, 3)) array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]) """ return _broadcast_to(array, shape, subok=subok, readonly=True) def _broadcast_shape(*args): """Returns the shape of the ararys that would result from broadcasting the supplied arrays against each other. """ if not args: raise ValueError('must provide at least one argument') # use the old-iterator because np.nditer does not handle size 0 arrays # consistently b = np.broadcast(*args[:32]) # unfortunately, it cannot handle 32 or more arguments directly for pos in range(32, len(args), 31): # ironically, np.broadcast does not properly handle np.broadcast # objects (it treats them as scalars) # use broadcasting to avoid allocating the full array b = broadcast_to(0, b.shape) b = np.broadcast(b, *args[pos:(pos + 31)]) return b.shape def broadcast_arrays(*args, **kwargs): """ Broadcast any number of arrays against each other. Parameters ---------- `*args` : array_likes The arrays to broadcast. subok : bool, optional If True, then sub-classes will be passed-through, otherwise the returned arrays will be forced to be a base-class array (default). Returns ------- broadcasted : list of arrays These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first. Examples -------- >>> x = np.array([[1,2,3]]) >>> y = np.array([[1],[2],[3]]) >>> np.broadcast_arrays(x, y) [array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]), array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])] Here is a useful idiom for getting contiguous copies instead of non-contiguous views. >>> [np.array(a) for a in np.broadcast_arrays(x, y)] [array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]), array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])] """ # nditer is not used here to avoid the limit of 32 arrays. # Otherwise, something like the following one-liner would suffice: # return np.nditer(args, flags=['multi_index', 'zerosize_ok'], # order='C').itviews subok = kwargs.pop('subok', False) if kwargs: raise TypeError('broadcast_arrays() got an unexpected keyword ' 'argument {}'.format(kwargs.pop())) args = [np.array(_m, copy=False, subok=subok) for _m in args] shape = _broadcast_shape(*args) if all(array.shape == shape for array in args): # Common case where nothing needs to be broadcasted. return args # TODO: consider making the results of broadcast_arrays readonly to match # broadcast_to. This will require a deprecation cycle. return [_broadcast_to(array, shape, subok=subok, readonly=False) for array in args]
Upload File
Create Folder