Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reshape_input(a):
if do_full_array:
d = a.ravel()[None, :]
else:
# reshape the array to 2D
# axis 0: preserved axis after histogram
# axis 1: calculate histogram along this axis
new_pos = tuple(range(-len(axis), 0))
c = np.moveaxis(a, axis, new_pos)
split_idx = c.ndim - len(axis)
dims_0 = c.shape[:split_idx]
assert dims_0 == kept_axes_shape
dims_1 = c.shape[split_idx:]
new_dim_0 = np.prod(dims_0)
new_dim_1 = np.prod(dims_1)
d = reshape(c, (new_dim_0, new_dim_1))
return d
if weights is not None:
weights_reshaped = all_args_reshaped.pop()
else:
weights_reshaped = None
h = _histogram_2d_vectorized(*all_args_reshaped, bins=bins,
weights=weights_reshaped,
density=density, block_size=block_size)
if h.shape[0] == 1:
assert do_full_array
h = h.squeeze()
else:
final_shape = kept_axes_shape + h.shape[1:]
h = reshape(h, final_shape)
return h