Download lib/python3.9/site-packages/caffe2/python/operator_test/assert_test.py from camenduru/slahmr-test: direct link, hf CLI and curl.
- Browser
- Download file 797 Bytes
-
https://huggingface.co/camenduru/slahmr-test/resolve/main/lib/python3.9/site-packages/caffe2/python/operator_test/assert_test.py
- Command line
-
hf download hf://camenduru/slahmr-test/lib/python3.9/site-packages/caffe2/python/operator_test/assert_test.py
-
curl -L -o assert_test.py https://huggingface.co/camenduru/slahmr-test/resolve/main/lib/python3.9/site-packages/caffe2/python/operator_test/assert_test.py
797 Bytes
| import numpy as np | |
| from hypothesis import given, settings | |
| import hypothesis.strategies as st | |
| from caffe2.python import core | |
| import caffe2.python.hypothesis_test_util as hu | |
| class TestAssert(hu.HypothesisTestCase): | |
| def test_assert(self, dtype, shape, gc, dc): | |
| test_tensor = np.random.rand(*shape).astype(np.dtype(dtype)) | |
| op = core.CreateOperator('Assert', ['X'], []) | |
| def assert_ref(X): | |
| return [] | |
| try: | |
| self.assertReferenceChecks(gc, op, [test_tensor], assert_ref) | |
| except Exception: | |
| assert(not np.all(test_tensor)) | |