Python numpy.longlong() Examples
The following are 30 code examples for showing how to use numpy.longlong(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example 1
Project: mars Author: mars-project File: histogram.py License: 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
Project: lambda-packs Author: ryfeus File: histograms.py License: 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
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: histograms.py License: 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
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: svmlight_format.py License: MIT License | 6 votes |
def _open_and_load(f, dtype, multilabel, zero_based, query_id, offset=0, length=-1): if hasattr(f, "read"): actual_dtype, data, ind, indptr, labels, query = \ _load_svmlight_file(f, dtype, multilabel, zero_based, query_id, offset, length) else: with closing(_gen_open(f)) as f: actual_dtype, data, ind, indptr, labels, query = \ _load_svmlight_file(f, dtype, multilabel, zero_based, query_id, offset, length) # convert from array.array, give data the right dtype if not multilabel: labels = np.frombuffer(labels, np.float64) data = np.frombuffer(data, actual_dtype) indices = np.frombuffer(ind, np.longlong) indptr = np.frombuffer(indptr, dtype=np.longlong) # never empty query = np.frombuffer(query, np.int64) data = np.asarray(data, dtype=dtype) # no-op for float{32,64} return data, indices, indptr, labels, query
Example 5
Project: GraphicDesignPatternByPython Author: Relph1119 File: histograms.py License: 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
Project: predictive-maintenance-using-machine-learning Author: awslabs File: histograms.py License: 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 7
Project: pySINDy Author: luckystarufo File: histograms.py License: 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 8
Project: ssds Author: TomohikoMukai File: main.py License: MIT License | 6 votes |
def concatenateNeighborLists(meshPaths): neighbor = [] for path in meshPaths: mesh = om.MFnMesh(path) _, indices = mesh.getTriangles() offset = len(neighbor) neighbor = neighbor + [set() for v in xrange(mesh.numVertices)] for l in xrange(len(indices) / 3): i0 = indices[l * 3 + 0] + offset i1 = indices[l * 3 + 1] + offset i2 = indices[l * 3 + 2] + offset neighbor[i0].add(i1) neighbor[i0].add(i2) neighbor[i1].add(i0) neighbor[i1].add(i2) neighbor[i2].add(i0) neighbor[i2].add(i1) maxlen = 0 for i in xrange(len(neighbor)): maxlen = max(maxlen, len(neighbor[i])) retval = -np.ones([len(neighbor), maxlen], dtype = np.longlong) for i in xrange(len(neighbor)): retval[i, 0:len(neighbor[i])] = list(neighbor[i]) return retval
Example 9
Project: coffeegrindsize Author: jgagneastro File: histograms.py License: 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
Project: Carnets Author: holzschu File: histograms.py License: 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 11
Project: Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda Author: PacktPublishing File: histograms.py License: 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 12
Project: twitter-stock-recommendation Author: alvarobartt File: histograms.py License: 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 13
Project: recruit Author: Frank-qlu File: histograms.py License: 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 14
Project: recruit Author: Frank-qlu File: test_histograms.py License: Apache License 2.0 | 5 votes |
def test_signed_overflow_bounds(self): self.do_signed_overflow_bounds(np.byte) self.do_signed_overflow_bounds(np.short) self.do_signed_overflow_bounds(np.intc) self.do_signed_overflow_bounds(np.int_) self.do_signed_overflow_bounds(np.longlong)
Example 15
Project: recruit Author: Frank-qlu File: test_numerictypes.py License: Apache License 2.0 | 5 votes |
def test_platform_dependent_aliases(self): if np.int64 is np.int_: assert_('int64' in np.int_.__doc__) elif np.int64 is np.longlong: assert_('int64' in np.longlong.__doc__)
Example 16
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_histograms.py License: MIT License | 5 votes |
def test_signed_overflow_bounds(self): self.do_signed_overflow_bounds(np.byte) self.do_signed_overflow_bounds(np.short) self.do_signed_overflow_bounds(np.intc) self.do_signed_overflow_bounds(np.int_) self.do_signed_overflow_bounds(np.longlong)
Example 17
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_numerictypes.py License: MIT License | 5 votes |
def test_platform_dependent_aliases(self): if np.int64 is np.int_: assert_('int64' in np.int_.__doc__) elif np.int64 is np.longlong: assert_('int64' in np.longlong.__doc__)
Example 18
Project: trax Author: google File: lax_numpy_test.py License: Apache License 2.0 | 5 votes |
def testLongLong(self): self.assertAllClose( onp.int64(7), npe.jit(lambda x: x)(onp.longlong(7)), check_dtypes=True)
Example 19
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_histograms.py License: MIT License | 5 votes |
def test_signed_overflow_bounds(self): self.do_signed_overflow_bounds(np.byte) self.do_signed_overflow_bounds(np.short) self.do_signed_overflow_bounds(np.intc) self.do_signed_overflow_bounds(np.int_) self.do_signed_overflow_bounds(np.longlong)
Example 20
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_decomp.py License: MIT License | 5 votes |
def test_eigvals_banded(self): """Compare eigenvalues of eigvals_banded with those of linalg.eig.""" w_sym = eigvals_banded(self.bandmat_sym) w_sym = w_sym.real assert_array_almost_equal(sort(w_sym), self.w_sym_lin) w_herm = eigvals_banded(self.bandmat_herm) w_herm = w_herm.real assert_array_almost_equal(sort(w_herm), self.w_herm_lin) # extracting eigenvalues with respect to an index range ind1 = 2 ind2 = np.longlong(6) w_sym_ind = eigvals_banded(self.bandmat_sym, select='i', select_range=(ind1, ind2)) assert_array_almost_equal(sort(w_sym_ind), self.w_sym_lin[ind1:ind2+1]) w_herm_ind = eigvals_banded(self.bandmat_herm, select='i', select_range=(ind1, ind2)) assert_array_almost_equal(sort(w_herm_ind), self.w_herm_lin[ind1:ind2+1]) # extracting eigenvalues with respect to a value range v_lower = self.w_sym_lin[ind1] - 1.0e-5 v_upper = self.w_sym_lin[ind2] + 1.0e-5 w_sym_val = eigvals_banded(self.bandmat_sym, select='v', select_range=(v_lower, v_upper)) assert_array_almost_equal(sort(w_sym_val), self.w_sym_lin[ind1:ind2+1]) v_lower = self.w_herm_lin[ind1] - 1.0e-5 v_upper = self.w_herm_lin[ind2] + 1.0e-5 w_herm_val = eigvals_banded(self.bandmat_herm, select='v', select_range=(v_lower, v_upper)) assert_array_almost_equal(sort(w_herm_val), self.w_herm_lin[ind1:ind2+1]) w_sym = eigvals_banded(self.bandmat_sym, check_finite=False) w_sym = w_sym.real assert_array_almost_equal(sort(w_sym), self.w_sym_lin)
Example 21
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_histograms.py License: Apache License 2.0 | 5 votes |
def test_signed_overflow_bounds(self): self.do_signed_overflow_bounds(np.byte) self.do_signed_overflow_bounds(np.short) self.do_signed_overflow_bounds(np.intc) self.do_signed_overflow_bounds(np.int_) self.do_signed_overflow_bounds(np.longlong)
Example 22
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_numerictypes.py License: Apache License 2.0 | 5 votes |
def test_platform_dependent_aliases(self): if np.int64 is np.int_: assert_('int64' in np.int_.__doc__) elif np.int64 is np.longlong: assert_('int64' in np.longlong.__doc__)
Example 23
Project: pySINDy Author: luckystarufo File: test_histograms.py License: MIT License | 5 votes |
def test_signed_overflow_bounds(self): self.do_signed_overflow_bounds(np.byte) self.do_signed_overflow_bounds(np.short) self.do_signed_overflow_bounds(np.intc) self.do_signed_overflow_bounds(np.int_) self.do_signed_overflow_bounds(np.longlong)
Example 24
Project: eliot Author: itamarst File: test_json.py License: 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 25
Project: khiva-python Author: shapelets File: array.py License: Mozilla Public License 2.0 | 5 votes |
def get_dims(self): """ Gets the dimensions of the KHIVA array. :return: The dimensions of the KHIVA array. """ c_array_n = (ctypes.c_longlong * 4)(*(np.zeros(4)).astype(np.longlong)) error_code = ctypes.c_int(0) error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH) KhivaLibrary().c_khiva_library.get_dims(ctypes.pointer(self.arr_reference), ctypes.pointer(c_array_n), ctypes.pointer(error_code), error_message) return np.array(c_array_n)
Example 26
Project: hope Author: jakeret File: test_return.py License: 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 27
Project: hope Author: jakeret File: test_return.py License: 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 28
Project: hope Author: jakeret File: test_return.py License: 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 29
Project: qPython Author: exxeleron File: qtemporal.py License: Apache License 2.0 | 5 votes |
def _to_qtimestamp(dt): t_dt = type(dt) if t_dt == numpy.int64: return dt elif t_dt == numpy.datetime64: return (dt - _EPOCH_TIMESTAMP).astype(longlong) if not dt == _NUMPY_NULL[QTIMESTAMP] else _QTIMESTAMP_NULL else: raise ValueError('Cannot convert %s of type %s to q value.' % (dt, type(dt)))
Example 30
Project: qPython Author: exxeleron File: qtemporal.py License: Apache License 2.0 | 5 votes |
def _to_qtimespan(dt): t_dt = type(dt) if t_dt == numpy.int64: return dt elif t_dt == numpy.timedelta64: return dt.astype(longlong) if not dt == _NUMPY_NULL[QTIMESPAN] else _QTIMESTAMP_NULL else: raise ValueError('Cannot convert %s of type %s to q value.' % (dt, type(dt)))