MCPcopy Index your code
hub / github.com/numpy/numpy / _broadcast_to

Function _broadcast_to

numpy/lib/_stride_tricks_impl.py:447–467  ·  view source on GitHub ↗
(array, shape, subok, readonly)

Source from the content-addressed store, hash-verified

445
446
447def _broadcast_to(array, shape, subok, readonly):
448 shape = tuple(shape) if np.iterable(shape) else (shape,)
449 array = np.array(array, copy=None, subok=subok)
450 if not shape and array.shape:
451 raise ValueError('cannot broadcast a non-scalar to a scalar array')
452 if any(size < 0 for size in shape):
453 raise ValueError('all elements of broadcast shape must be non-'
454 'negative')
455 extras = []
456 it = np.nditer(
457 (array,), flags=['multi_index', 'refs_ok', 'zerosize_ok'] + extras,
458 op_flags=['readonly'], itershape=shape, order='C')
459 with it:
460 # never really has writebackifcopy semantics
461 broadcast = it.itviews[0]
462 result = _maybe_view_as_subclass(array, broadcast)
463 # In a future version this will go away
464 if not readonly and array.flags._writeable_no_warn:
465 result.flags.writeable = True
466 result.flags._warn_on_write = True
467 return result
468
469
470def _broadcast_to_dispatcher(array, shape, subok=None):

Callers 2

broadcast_toFunction · 0.85
broadcast_arraysFunction · 0.85

Calls 2

anyFunction · 0.85
_maybe_view_as_subclassFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…