NumPy
Np.clip
Clip (limit) The values in an array.
Given an interval, values outside the interval is clipped to the interval edges. For example, if a interval of is [0, 1] specified, values smaller than 0 become 0, and values larger than 1 become 1.
>>> a = Np.arange (ten)>>> Np.clip (A, 1, 8) Array ([1, 1, 2, 3, 4, 5, 6, 7, 8, 8]) >>>1, 2, 3, 4, 5, 6, 7, 8, 9])>>> Np.clip (A, 3, 6, out=a) array ([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])>>> a = Np.arange (ten)>>>1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> Np.clip (A, [3, 4, 1, 1, 1, 4, 4, 4, 4, 4], 8) Array ([3, 4, 2, 3, 4, 5, 6, 7, 8, 8])
Np.flatnonezero
Return indices that is non-zero in the flattened version of a.
>>> x = Np.arange ( -2, 3)>>> Xarray ([-2,-1, 0, 1, 2])> >>1, 3, 4])
Np.concatenate
Join a sequence of arrays along an existing axis.
>>> a = Np.array ([[1, 2], [3, 4]])>>> b = Np.array ([[5, 6]])>>> Np.concatena Te ((A, B), axis=0) Array ([[[1,2], [3, 4], [5, 6]])>>> Np.concatenate ((A, b.t), Axis=1) Array ([[1, 2, 5], [3, 4, 6]])
>>> a = Np.ma.arange (3)>>> A[1] =np.ma.masked>>> B = Np.arange (2, 5)>>>Amasked_array (Data= [0--2], Mask=[False True false], Fill_value= 999999)>>>Barray ([2, 3, 4])>>>Np.concatenate ([A, b]) Masked_array (data= [0 1 2 2 3 4], Mask=False, Fill_value= 999999)>>>Np.ma.concatenate ([A, b]) Masked_array (data= [0--2 2 3 4], Mask=[False True false to false], Fill_value= 999999)
Np.mod
Computes the remainder complementary to the floor_divide function. It is equivalent to the Python modulus operator ' X1% X2 ' and have the same sign as the divisor x2. The MATLAB function equivalent to np.remainder is mod .
>>> Np.remainder ([4, 7], [2, 31])>>> np.remainder (Np.arange (7), 51, 2, 3, 4, 0, 1])
Https://docs.scipy.org/doc/numpy/reference/generated/numpy.mod.html
Np.empty
NumPy. Empty (shape, dtype=float, order= ' C ')
Return a new array of given shape and type, without initializing entries.
>>> Np.empty ([2, 2-9.74499359e+001, 6.69583040e-309], [ 2.13182611e-314, 3.06959433e-309]) # Random
>>> Np.empty ([2, 2], dtype=int) array ([[ -1073741821, -1067949133], [ 496041986, 19249760]] #Random
Python Learning Notes (Miscellaneous)