Download tests/test_model_utils.py from iamrahulreddy/L31H14-plus: direct link, hf CLI and curl.
- Browser
- Download file 527 Bytes
-
https://huggingface.co/iamrahulreddy/L31H14-plus/resolve/main/tests/test_model_utils.py
- Command line
-
hf download hf://iamrahulreddy/L31H14-plus/tests/test_model_utils.py
-
curl -L -o test_model_utils.py https://huggingface.co/iamrahulreddy/L31H14-plus/resolve/main/tests/test_model_utils.py
527 Bytes
| import math | |
| from mech_workbench.model_utils import is_finite, safe_mean | |
| def test_is_finite(): | |
| assert is_finite(1.0) | |
| assert is_finite(0) | |
| assert is_finite(-5.5) | |
| assert not is_finite(math.nan) | |
| assert not is_finite(math.inf) | |
| assert not is_finite(-math.inf) | |
| assert not is_finite("abc") | |
| assert not is_finite(None) | |
| def test_safe_mean(): | |
| assert safe_mean([1.0, 2.0, 3.0]) == 2.0 | |
| assert safe_mean([0.0, 0.0]) == 0.0 | |
| assert math.isnan(safe_mean([])) | |
| assert safe_mean([-1.0, 1.0]) == 0.0 | |