MCPcopy
hub / github.com/numpy/numpy / _unsigned_subtract

Function _unsigned_subtract

numpy/lib/_histograms_impl.py:328–353  ·  view source on GitHub ↗

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

(a, b)

Source from the content-addressed store, hash-verified

326
327
328def _unsigned_subtract(a, b):
329 """
330 Subtract two values where a >= b, and produce an unsigned result
331
332 This is needed when finding the difference between the upper and lower
333 bound of an int16 histogram
334 """
335 # coerce to a single type
336 signed_to_unsigned = {
337 np.byte: np.ubyte,
338 np.short: np.ushort,
339 np.intc: np.uintc,
340 np.int_: np.uint,
341 np.longlong: np.ulonglong
342 }
343 dt = np.result_type(a, b)
344 try:
345 unsigned_dt = signed_to_unsigned[dt.type]
346 except KeyError:
347 return np.subtract(a, b, dtype=type(dt))
348 else:
349 # we know the inputs are integers, and we are deliberately casting
350 # signed to unsigned. The input may be negative python integers so
351 # ensure we pass in arrays with the initial dtype (related to NEP 50).
352 return np.subtract(np.asarray(a, dtype=dt), np.asarray(b, dtype=dt),
353 casting='unsafe', dtype=unsigned_dt)
354
355
356def _get_bin_edges(a, bins, range, weights):

Callers 4

_ptpFunction · 0.85
_get_bin_edgesFunction · 0.85
histogramFunction · 0.85

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…