| import math | |
| import pytest | |
| from mitointeract_recovery import micromolar_to_paffinity, paffinity_to_micromolar | |
| def test_one_micromolar_is_paffinity_six(): | |
| assert micromolar_to_paffinity(1.0) == pytest.approx(6.0) | |
| def test_dataset_example_500_micromolar(): | |
| assert micromolar_to_paffinity(500.0) == pytest.approx(3.3010299957) | |
| def test_round_trip(paffinity): | |
| assert micromolar_to_paffinity(paffinity_to_micromolar(paffinity)) == pytest.approx( | |
| paffinity | |
| ) | |
| def test_invalid_affinity_rejected(bad): | |
| with pytest.raises(ValueError): | |
| micromolar_to_paffinity(bad) | |
| def test_nonfinite_paffinity_rejected(): | |
| with pytest.raises(ValueError): | |
| paffinity_to_micromolar(math.nan) | |