Python numpy.ulonglong() Examples
The following are 18
code examples of numpy.ulonglong().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example #1
Source File: histogram.py From mars with Apache License 2.0 | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: # pragma: no cover return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #2
Source File: histograms.py From twitter-stock-recommendation with MIT License | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #3
Source File: histograms.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #4
Source File: histograms.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #5
Source File: histograms.py From coffeegrindsize with MIT License | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #6
Source File: histograms.py From pySINDy with MIT License | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #7
Source File: histograms.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #8
Source File: histograms.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #9
Source File: histograms.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #10
Source File: histograms.py From lambda-packs with MIT License | 6 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #11
Source File: scatter_add.py From chainer with MIT License | 5 votes |
def scatter_add(a, slices, b): """Adds given values to specified elements of an array. This function adds ``b`` to the specified elements of the copy of ``a``, and returns the copy. The value of the original ``a`` is not changed. Args: a (:class:`~chainer.Variable` or :ref:`ndarray`): A variable. slices (int, slice, Ellipsis, None, integer array-like, boolean\ array-like or tuple of them): It is an integer, a slice, an ellipsis, a numpy.newaxis, an integer array-like, a boolean array-like or tuple of them. b (:class:`~chainer.Variable` or :ref:`ndarray`): A variable that is scatter added to ``a``. Its shape has to equal ``a[slices]`` because broadcasting of variables is not supported. Returns: A :class:`~chainer.Variable` object which is the result of scatter addition. .. note:: It only supports types that are supported by CUDA's atomicAdd when an integer array is included in ``slices``. The supported types are ``numpy.float32``, ``numpy.int32``, ``numpy.uint32``, ``numpy.uint64`` and ``numpy.ulonglong``. .. note:: It does not support ``slices`` that contains multiple boolean arrays. .. seealso:: :func:`numpy.add.at` and :func:`cupyx.scatter_add`. """ y, = ScatterAdd(slices).apply((a, b)) return y
Example #12
Source File: test_json.py From eliot with Apache License 2.0 | 5 votes |
def test_numpy(self): """NumPy objects get serialized to readable JSON.""" l = [ np.float32(12.5), np.float64(2.0), np.float16(0.5), np.bool(True), np.bool(False), np.bool_(True), np.unicode_("hello"), np.byte(12), np.short(12), np.intc(-13), np.int_(0), np.longlong(100), np.intp(7), np.ubyte(12), np.ushort(12), np.uintc(13), np.ulonglong(100), np.uintp(7), np.int8(1), np.int16(3), np.int32(4), np.int64(5), np.uint8(1), np.uint16(3), np.uint32(4), np.uint64(5), ] l2 = [l, np.array([1, 2, 3])] roundtripped = loads(dumps(l2, cls=EliotJSONEncoder)) self.assertEqual([l, [1, 2, 3]], roundtripped)
Example #13
Source File: test_return.py From hope with GNU General Public License v3.0 | 5 votes |
def test_return_arrcrt_zeros(a, b, c): d = np.zeros(3) d[:] = 2 d[0] = 1 return d # TODO: fix for np.ulonglong, np.longlong and uint64
Example #14
Source File: test_return.py From hope with GNU General Public License v3.0 | 5 votes |
def test_return_scalar(dtype): def fkt(a): return a ao, ah = random(dtype, []) ro, rh = fkt(ao), hope.jit(fkt)(ah) assert check(ro, rh) # TODO: fix for np.ulonglong, np.longlong and uint64
Example #15
Source File: test_return.py From hope with GNU General Public License v3.0 | 5 votes |
def test_return_arrayscalar(dtype): def fkt(a): return a[2] ao, ah = random(dtype, [10]) ro, rh = fkt(ao), hope.jit(fkt)(ah) assert check(ro, rh) # TODO: fix for np.ulonglong, np.longlong and uint64
Example #16
Source File: test_op_pow.py From hope with GNU General Public License v3.0 | 5 votes |
def test_augmented_pow(dtype, shape): def fkt(a, c): c[:] **= a hfkt = hope.jit(fkt) (ao, ah), (co, ch) = random(np.uint8, shape), random(dtype, shape) if np.count_nonzero(ao == 0) > 0: ao[ao == 0] += 1 if np.count_nonzero(ah == 0) > 0: ah[ah == 0] += 1 if np.count_nonzero(co == 0) > 0: co[co == 0] += 1 if np.count_nonzero(ch == 0) > 0: ch[ch == 0] += 1 co, ch = np.copysign(np.sqrt(np.abs(co)), co).astype(dtype), np.copysign(np.sqrt(np.abs(ch)), ch).astype(dtype) ao, ah = np.power(np.abs(ao).astype(np.float64), 1. / co.astype(np.float64)).astype(dtype), np.power(np.abs(ah).astype(np.float64), 1. / ch.astype(np.float64)).astype(dtype) fkt(ao, co), hfkt(ah, ch) assert check(co, ch) # TODO: fix for np.ulonglong and uint64, std::power produce different results
Example #17
Source File: histograms.py From recruit with Apache License 2.0 | 5 votes |
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.short: np.ushort, np.intc: np.uintc, np.int_: np.uint, np.longlong: np.ulonglong } dt = np.result_type(a, b) try: dt = signed_to_unsigned[dt.type] except KeyError: return np.subtract(a, b, dtype=dt) else: # we know the inputs are integers, and we are deliberately casting # signed to unsigned return np.subtract(a, b, casting='unsafe', dtype=dt)
Example #18
Source File: get_item.py From chainer with MIT License | 4 votes |
def get_item(x, slices): """Extract elements from array with specified shape, axes and offsets. Args: x (:class:`~chainer.Variable` or :ref:`ndarray`): A variable to be sliced. slices (int, slice, Ellipsis, None, integer array-like, boolean\ array-like or tuple of them): An object to specify the selection of elements. Returns: A :class:`~chainer.Variable` object which contains sliced array of ``x``. .. note:: It only supports types that are supported by CUDA's atomicAdd when an integer array is included in ``slices``. The supported types are ``numpy.float32``, ``numpy.int32``, ``numpy.uint32``, ``numpy.uint64`` and ``numpy.ulonglong``. .. note:: It does not support ``slices`` that contains multiple boolean arrays. .. note:: See NumPy documentation for details of `indexing <https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html>`_. .. admonition:: Example >>> x = np.arange(12).reshape((2, 2, 3)) >>> x array([[[ 0, 1, 2], [ 3, 4, 5]], <BLANKLINE> [[ 6, 7, 8], [ 9, 10, 11]]]) >>> F.get_item(x, 0) variable([[0, 1, 2], [3, 4, 5]]) >>> F.get_item(x, (0, 0, slice(0, 2, 1))) # equals x[0, 0, 0:2:1] variable([0, 1]) >>> F.get_item(x, (Ellipsis, 2)) # equals x[..., 2] variable([[ 2, 5], [ 8, 11]]) >>> F.get_item(x, (1, np.newaxis, 1, 0)) # equals x[1, None, 1, 0] variable([9]) """ return GetItem(slices).apply((x,))[0]