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)
| 332 | |
| 333 | |
| 334 | def _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 | |
| 360 | def _get_bin_edges(a, bins, range, weights): |
no outgoing calls
no test coverage detected