I am running a Python script inside a Bash script. I use NumPy’s assert_allclose
and assert
at multiple places. I would like to run this Python script by disabling all such instances without manually commenting them out.
Here is a simple example:
python run.py
if __name__ == "__main__":
assert False
np.assert_allclose(1, 2)
I am aware of -O
flag that can be added to python run.py
. But this doesn’t seem to disable the NumPy’s assertion as np.assert_allclose
uses raise AssertionError(msg)
rather than assert
itself.