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

Function assert_

numpy/testing/_private/utils.py:71–88  ·  view source on GitHub ↗

Assert that works in release mode. Accepts callable msg to allow deferring evaluation until failure. The Python built-in ``assert`` does not work when executing code in optimized mode (the ``-O`` flag) - no byte-code is generated for it. For documentation on usage, refer to th

(val, msg='')

Source from the content-addressed store, hash-verified

69
70
71def assert_(val, msg=''):
72 """
73 Assert that works in release mode.
74 Accepts callable msg to allow deferring evaluation until failure.
75
76 The Python built-in ``assert`` does not work when executing code in
77 optimized mode (the ``-O`` flag) - no byte-code is generated for it.
78
79 For documentation on usage, refer to the Python documentation.
80
81 """
82 __tracebackhide__ = True # Hide traceback for py.test
83 if not val:
84 try:
85 smsg = msg()
86 except TypeError:
87 smsg = msg
88 raise AssertionError(smsg)
89
90
91if os.name == 'nt':

Callers 15

test_n_zeroMethod · 0.90
test_basicMethod · 0.90
test_gaussian_resetMethod · 0.90
test_in_bounds_fuzzMethod · 0.90
test_repeatabilityMethod · 0.90
test_random_integersMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_n_zeroMethod · 0.72
test_basicMethod · 0.72
test_gaussian_resetMethod · 0.72
test_in_bounds_fuzzMethod · 0.72
test_repeatabilityMethod · 0.72
test_random_integersMethod · 0.72