diff options
author | Stephan Hoyer <shoyer@google.com> | 2019-05-13 08:09:26 -0700 |
---|---|---|
committer | Stephan Hoyer <shoyer@google.com> | 2019-05-13 08:09:26 -0700 |
commit | 07452c86c78a1cf213a764d17f060b4887ec3681 (patch) | |
tree | 12c7ae7b14552bd28334277e7e244b603ca4300a /numpy/core/multiarray.py | |
parent | 804f71bb42fef775a85a52366dc4bd1a22c130a8 (diff) | |
parent | 4ad33d21b1a30f931e23307e9f9355b70f633bed (diff) | |
download | numpy-07452c86c78a1cf213a764d17f060b4887ec3681.tar.gz |
Merge branch 'master' into implement-numpy-implementation
Diffstat (limited to 'numpy/core/multiarray.py')
-rw-r--r-- | numpy/core/multiarray.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 54b3a3e5e..78fec1aab 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -8,6 +8,7 @@ by importing from the extension module. import functools import warnings +import sys from . import overrides from . import _multiarray_umath @@ -71,9 +72,9 @@ array_function_from_c_func_and_dispatcher = functools.partial( @array_function_from_c_func_and_dispatcher(_multiarray_umath.empty_like) -def empty_like(prototype, dtype=None, order=None, subok=None): +def empty_like(prototype, dtype=None, order=None, subok=None, shape=None): """ - empty_like(prototype, dtype=None, order='K', subok=True) + empty_like(prototype, dtype=None, order='K', subok=True, shape=None) Return a new array with the same shape and type as a given array. @@ -97,6 +98,12 @@ def empty_like(prototype, dtype=None, order=None, subok=None): If True, then the newly created array will use the sub-class type of 'a', otherwise it will be a base-class array. Defaults to True. + shape : int or sequence of ints, optional. + Overrides the shape of the result. If order='K' and the number of + dimensions is unchanged, will try to keep order, otherwise, + order='C' is implied. + + .. versionadded:: 1.17.0 Returns ------- @@ -1107,7 +1114,7 @@ def putmask(a, mask, values): @array_function_from_c_func_and_dispatcher(_multiarray_umath.packbits) -def packbits(a, axis=None): +def packbits(a, axis=None, bitorder='big'): """ packbits(a, axis=None) @@ -1123,6 +1130,13 @@ def packbits(a, axis=None): axis : int, optional The dimension over which bit-packing is done. ``None`` implies packing the flattened array. + bitorder : {'big', 'little'}, optional + The order of the input bits. 'big' will mimic bin(val), + ``[0, 0, 0, 0, 0, 0, 1, 1] => 3 = 0b00000011 => ``, 'little' will + reverse the order so ``[1, 1, 0, 0, 0, 0, 0, 0] => 3``. + Defaults to 'big'. + + .. versionadded:: 1.17.0 Returns ------- @@ -1158,7 +1172,7 @@ def packbits(a, axis=None): @array_function_from_c_func_and_dispatcher(_multiarray_umath.unpackbits) -def unpackbits(a, axis=None, count=None): +def unpackbits(a, axis=None, count=None, bitorder='big'): """ unpackbits(a, axis=None, count=None) @@ -1188,6 +1202,14 @@ def unpackbits(a, axis=None, count=None): .. versionadded:: 1.17.0 + bitorder : {'big', 'little'}, optional + The order of the returned bits. 'big' will mimic bin(val), + ``3 = 0b00000011 => [0, 0, 0, 0, 0, 0, 1, 1]``, 'little' will reverse + the order to ``[1, 1, 0, 0, 0, 0, 0, 0]``. + Defaults to 'big'. + + .. versionadded:: 1.17.0 + Returns ------- unpacked : ndarray, uint8 type |