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

Function check_internal_overlap

numpy/_core/tests/test_mem_overlap.py:453–474  ·  view source on GitHub ↗
(a, manual_expected=None)

Source from the content-addressed store, hash-verified

451
452
453def check_internal_overlap(a, manual_expected=None):
454 got = internal_overlap(a)
455
456 # Brute-force check
457 m = set()
458 ranges = tuple(range(n) for n in a.shape)
459 for v in itertools.product(*ranges):
460 offset = sum(s * w for s, w in zip(a.strides, v))
461 if offset in m:
462 expected = True
463 break
464 else:
465 m.add(offset)
466 else:
467 expected = False
468
469 # Compare
470 if got != expected:
471 assert_equal(got, expected, err_msg=repr((a.strides, a.shape)))
472 if manual_expected is not None and expected != manual_expected:
473 assert_equal(expected, manual_expected)
474 return got
475
476
477def test_internal_overlap_manual():

Callers 2

Calls 3

assert_equalFunction · 0.90
sumFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…