Download tests/conftest.py from ChatterjeeLab/CIS6270: direct link, hf CLI and curl.
- Browser
- Download file 948 Bytes
-
https://huggingface.co/ChatterjeeLab/CIS6270/resolve/main/tests/conftest.py
- Command line
-
hf download hf://ChatterjeeLab/CIS6270/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/ChatterjeeLab/CIS6270/resolve/main/tests/conftest.py
948 Bytes
| """Shared setup for the test suite. | |
| Several lecture files print five decimal places of an arithmetic result, too close for float32 | |
| to separate, so those files raise the default precision when they are imported. A test may import a | |
| file that does not, so the suite raises the precision here for every test alike. | |
| We run this at module scope, not in a fixture, because pytest imports a conftest before it | |
| imports or collects anything else. A module-scoped fixture in a test file would otherwise build | |
| its values first, in the lower precision. | |
| """ | |
| import pytest | |
| import torch | |
| torch.set_default_dtype(torch.float64) # Match what every script does in main(). | |
| torch.set_num_threads(1) # One thread is the fastest here, because these networks are small. | |
| def _restore_defaults(): | |
| """Put the process back the way it was once the session ends.""" | |
| yield | |
| torch.set_default_dtype(torch.float32) | |