Check a and weights have matching shapes, and ravel both
(a, weights)
| 281 | |
| 282 | |
| 283 | def _ravel_and_check_weights(a, weights): |
| 284 | """ Check a and weights have matching shapes, and ravel both """ |
| 285 | a = np.asarray(a) |
| 286 | |
| 287 | # Ensure that the array is a "subtractable" dtype |
| 288 | if a.dtype == np.bool_: |
| 289 | warnings.warn("Converting input from {} to {} for compatibility." |
| 290 | .format(a.dtype, np.uint8), |
| 291 | RuntimeWarning, stacklevel=3) |
| 292 | a = a.astype(np.uint8) |
| 293 | |
| 294 | if weights is not None: |
| 295 | weights = np.asarray(weights) |
| 296 | if weights.shape != a.shape: |
| 297 | raise ValueError( |
| 298 | 'weights should have the same shape as a.') |
| 299 | weights = weights.ravel() |
| 300 | a = a.ravel() |
| 301 | return a, weights |
| 302 | |
| 303 | |
| 304 | def _get_outer_edges(a, range): |
no test coverage detected