(left, right)
| 165 | |
| 166 | |
| 167 | def _get_absdiff(left, right): |
| 168 | def make_unsigned(dtype): |
| 169 | if not np.issubdtype(dtype, np.signedinteger): |
| 170 | return dtype |
| 171 | return { |
| 172 | np.dtype(np.int8): np.uint8, |
| 173 | np.dtype(np.int16): np.uint16, |
| 174 | np.dtype(np.int32): np.uint32, |
| 175 | np.dtype(np.int64): np.uint64, |
| 176 | }[dtype] |
| 177 | |
| 178 | # np.abs of diff doesn't handle overflow for unsigned types |
| 179 | absdiff = np.maximum(left, right) - np.minimum(left, right) |
| 180 | # max - min can overflow for signed types, wrap them up |
| 181 | absdiff = absdiff.astype(make_unsigned(absdiff.dtype)) |
| 182 | return absdiff |
| 183 | |
| 184 | |
| 185 | def _check_absdiff(): |
no test coverage detected