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

Function test_internal_overlap_fuzz

numpy/core/tests/test_mem_overlap.py:511–536  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

509
510
511def test_internal_overlap_fuzz():
512 # Fuzz check; the brute-force check is fairly slow
513
514 x = np.arange(1).astype(np.int8)
515
516 overlap = 0
517 no_overlap = 0
518 min_count = 100
519
520 rng = np.random.RandomState(1234)
521
522 while min(overlap, no_overlap) < min_count:
523 ndim = rng.randint(1, 4, dtype=np.intp)
524
525 strides = tuple(rng.randint(-1000, 1000, dtype=np.intp)
526 for j in range(ndim))
527 shape = tuple(rng.randint(1, 30, dtype=np.intp)
528 for j in range(ndim))
529
530 a = as_strided(x, strides=strides, shape=shape)
531 result = check_internal_overlap(a)
532
533 if result:
534 overlap += 1
535 else:
536 no_overlap += 1
537
538
539def test_non_ndarray_inputs():

Callers

nothing calls this directly

Calls 4

as_stridedFunction · 0.90
check_internal_overlapFunction · 0.85
astypeMethod · 0.80
minFunction · 0.50

Tested by

no test coverage detected