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

Function _ravel_and_check_weights

numpy/lib/histograms.py:283–301  ·  view source on GitHub ↗

Check a and weights have matching shapes, and ravel both

(a, weights)

Source from the content-addressed store, hash-verified

281
282
283def _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
304def _get_outer_edges(a, range):

Callers 2

histogram_bin_edgesFunction · 0.85
histogramFunction · 0.85

Calls 3

warnMethod · 0.80
astypeMethod · 0.80
ravelMethod · 0.45

Tested by

no test coverage detected