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

Function assert_copy_equivalent

numpy/core/tests/test_mem_overlap.py:576–594  ·  view source on GitHub ↗

Check that operation(*args, out=out) produces results equivalent to out[...] = operation(*args, out=out.copy())

(operation, args, out, **kwargs)

Source from the content-addressed store, hash-verified

574
575
576def assert_copy_equivalent(operation, args, out, **kwargs):
577 """
578 Check that operation(*args, out=out) produces results
579 equivalent to out[...] = operation(*args, out=out.copy())
580 """
581
582 kwargs['out'] = out
583 kwargs2 = dict(kwargs)
584 kwargs2['out'] = out.copy()
585
586 out_orig = out.copy()
587 out[...] = operation(*args, **kwargs2)
588 expected = out.copy()
589 out[...] = out_orig
590
591 got = operation(*args, **kwargs).copy()
592
593 if (got != expected).any():
594 assert_equal(got, expected)
595
596
597class TestUFunc:

Callers 2

check_unary_fuzzMethod · 0.85

Calls 3

assert_equalFunction · 0.90
copyMethod · 0.45
anyMethod · 0.45

Tested by

no test coverage detected