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

Function check_internal_overlap

numpy/core/tests/test_mem_overlap.py:450–471  ·  view source on GitHub ↗
(a, manual_expected=None)

Source from the content-addressed store, hash-verified

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

Callers 2

Calls 3

assert_equalFunction · 0.90
sumFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected