/
usr
/
lib64
/
python2.6
/
site-packages
/
numpy
/
lib
/
/usr/lib64/python2.6/site-packages/numpy/lib
mkdir
upload
Name
Size
Mode
Actions
benchmarks/
-
0755
rm
tests/
-
0755
rm
arraysetops.py
13704
0644
edit
dl
rm
arraysetops.pyc
13380
0644
edit
dl
rm
arraysetops.pyo
13380
0644
edit
dl
rm
arrayterator.py
6437
0644
edit
dl
rm
arrayterator.pyc
7022
0644
edit
dl
rm
arrayterator.pyo
7022
0644
edit
dl
rm
financial.py
20872
0644
edit
dl
rm
financial.pyc
21546
0644
edit
dl
rm
financial.pyo
21546
0644
edit
dl
rm
format.py
19309
0644
edit
dl
rm
format.pyc
17279
0644
edit
dl
rm
format.pyo
17279
0644
edit
dl
rm
function_base.py
100524
0644
edit
dl
rm
function_base.pyc
99169
0644
edit
dl
rm
function_base.pyo
99169
0644
edit
dl
rm
getlimits.py
8790
0644
edit
dl
rm
getlimits.pyc
10053
0644
edit
dl
rm
getlimits.pyo
10053
0644
edit
dl
rm
index_tricks.py
26790
0644
edit
dl
rm
index_tricks.pyc
28008
0644
edit
dl
rm
index_tricks.pyo
28008
0644
edit
dl
rm
info.py
6240
0644
edit
dl
rm
info.pyc
6425
0644
edit
dl
rm
info.pyo
6425
0644
edit
dl
rm
io.py
53226
0644
edit
dl
rm
io.pyc
44102
0644
edit
dl
rm
io.pyo
44102
0644
edit
dl
rm
machar.py
10658
0644
edit
dl
rm
machar.pyc
8688
0644
edit
dl
rm
machar.pyo
8688
0644
edit
dl
rm
polynomial.py
35562
0644
edit
dl
rm
polynomial.pyc
38139
0644
edit
dl
rm
polynomial.pyo
38139
0644
edit
dl
rm
recfunctions.py
32038
0644
edit
dl
rm
recfunctions.pyc
29451
0644
edit
dl
rm
recfunctions.pyo
29451
0644
edit
dl
rm
scimath.py
13997
0644
edit
dl
rm
scimath.pyc
15867
0644
edit
dl
rm
scimath.pyo
15867
0644
edit
dl
rm
setup.py
588
0644
edit
dl
rm
setup.pyc
918
0644
edit
dl
rm
setup.pyo
918
0644
edit
dl
rm
setupscons.py
470
0644
edit
dl
rm
setupscons.pyc
824
0644
edit
dl
rm
setupscons.pyo
824
0644
edit
dl
rm
shape_base.py
24387
0644
edit
dl
rm
shape_base.pyc
25291
0644
edit
dl
rm
shape_base.pyo
25291
0644
edit
dl
rm
stride_tricks.py
3972
0644
edit
dl
rm
stride_tricks.pyc
3863
0644
edit
dl
rm
stride_tricks.pyo
3863
0644
edit
dl
rm
twodim_base.py
22946
0644
edit
dl
rm
twodim_base.pyc
25464
0644
edit
dl
rm
twodim_base.pyo
25464
0644
edit
dl
rm
type_check.py
17075
0644
edit
dl
rm
type_check.pyc
18392
0644
edit
dl
rm
type_check.pyo
18392
0644
edit
dl
rm
ufunclike.py
5452
0644
edit
dl
rm
ufunclike.pyc
6311
0644
edit
dl
rm
ufunclike.pyo
6311
0644
edit
dl
rm
user_array.py
7475
0644
edit
dl
rm
user_array.pyc
15727
0644
edit
dl
rm
user_array.pyo
15727
0644
edit
dl
rm
utils.py
34034
0644
edit
dl
rm
utils.pyc
30422
0644
edit
dl
rm
utils.pyo
30422
0644
edit
dl
rm
_compiled_base.so
19720
0755
edit
dl
rm
_datasource.py
20638
0644
edit
dl
rm
_datasource.pyc
20986
0644
edit
dl
rm
_datasource.pyo
20986
0644
edit
dl
rm
_iotools.py
27712
0644
edit
dl
rm
_iotools.pyc
26916
0644
edit
dl
rm
_iotools.pyo
26916
0644
edit
dl
rm
__init__.py
936
0644
edit
dl
rm
__init__.pyc
1038
0644
edit
dl
rm
__init__.pyo
1038
0644
edit
dl
rm
Edit:
/usr/lib64/python2.6/site-packages/numpy/lib/stride_tricks.py
(3972B)
""" 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. """ import numpy as np __all__ = ['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 as_strided(x, shape=None, strides=None): """ Make an ndarray from the given array with the given shape and strides. """ interface = dict(x.__array_interface__) if shape is not None: interface['shape'] = tuple(shape) if strides is not None: interface['strides'] = tuple(strides) return np.asarray(DummyArray(interface, base=x)) def broadcast_arrays(*args): """ Broadcast any number of arrays against each other. Parameters ---------- `*args` : arrays The arrays to broadcast. 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. >>> map(np.array, 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]])] """ args = map(np.asarray, args) shapes = [x.shape for x in args] if len(set(shapes)) == 1: # Common case where nothing needs to be broadcasted. return args shapes = [list(s) for s in shapes] strides = [list(x.strides) for x in args] nds = [len(s) for s in shapes] biggest = max(nds) # Go through each array and prepend dimensions of length 1 to each of the # shapes in order to make the number of dimensions equal. for i in range(len(args)): diff = biggest - nds[i] if diff > 0: shapes[i] = [1] * diff + shapes[i] strides[i] = [0] * diff + strides[i] # Chech each dimension for compatibility. A dimension length of 1 is # accepted as compatible with any other length. common_shape = [] for axis in range(biggest): lengths = [s[axis] for s in shapes] unique = set(lengths + [1]) if len(unique) > 2: # There must be at least two non-1 lengths for this axis. raise ValueError("shape mismatch: two or more arrays have " "incompatible dimensions on axis %r." % (axis,)) elif len(unique) == 2: # There is exactly one non-1 length. The common shape will take this # value. unique.remove(1) new_length = unique.pop() common_shape.append(new_length) # For each array, if this axis is being broadcasted from a length of # 1, then set its stride to 0 so that it repeats its data. for i in range(len(args)): if shapes[i][axis] == 1: shapes[i][axis] = new_length strides[i][axis] = 0 else: # Every array has a length of 1 on this axis. Strides can be left # alone as nothing is broadcasted. common_shape.append(1) # Construct the new arrays. broadcasted = [as_strided(x, shape=sh, strides=st) for (x,sh,st) in zip(args, shapes, strides)] return broadcasted
Save
cmd:
run