MCPcopy Create free account
hub / github.com/numpy/numpy / _unsigned_subtract

Function _unsigned_subtract

numpy/lib/histograms.py:334–357  ·  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

332
333
334def _unsigned_subtract(a, b):
335 """
336 Subtract two values where a >= b, and produce an unsigned result
337
338 This is needed when finding the difference between the upper and lower
339 bound of an int16 histogram
340 """
341 # coerce to a single type
342 signed_to_unsigned = {
343 np.byte: np.ubyte,
344 np.short: np.ushort,
345 np.intc: np.uintc,
346 np.int_: np.uint,
347 np.longlong: np.ulonglong
348 }
349 dt = np.result_type(a, b)
350 try:
351 dt = signed_to_unsigned[dt.type]
352 except KeyError:
353 return np.subtract(a, b, dtype=dt)
354 else:
355 # we know the inputs are integers, and we are deliberately casting
356 # signed to unsigned
357 return np.subtract(a, b, casting='unsafe', dtype=dt)
358
359
360def _get_bin_edges(a, bins, range, weights):

Callers 3

_ptpFunction · 0.85
_get_bin_edgesFunction · 0.85
histogramFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected