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

Function test_internal_overlap_diophantine

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

Source from the content-addressed store, hash-verified

395
396
397def test_internal_overlap_diophantine():
398 def check(A, U, exists=None):
399 X = solve_diophantine(A, U, 0, require_ub_nontrivial=1)
400
401 if exists is None:
402 exists = (X is not None)
403
404 if X is not None:
405 assert_(sum(a*x for a, x in zip(A, X)) == sum(a*u//2 for a, u in zip(A, U)))
406 assert_(all(0 <= x <= u for x, u in zip(X, U)))
407 assert_(any(x != u//2 for x, u in zip(X, U)))
408
409 if exists:
410 assert_(X is not None, repr(X))
411 else:
412 assert_(X is None, repr(X))
413
414 # Smoke tests
415 check((3, 2), (2*2, 3*2), exists=True)
416 check((3*2, 2), (15*2, (3-1)*2), exists=False)
417
418
419def test_internal_overlap_slices():

Callers

nothing calls this directly

Calls 1

checkFunction · 0.85

Tested by

no test coverage detected