File size: 866 Bytes
7bf19c3 6019d52 7bf19c3 6019d52 7bf19c3 6019d52 7bf19c3 6019d52 7bf19c3 6019d52 7bf19c3 6019d52 7bf19c3 6019d52 7bf19c3 6019d52 7bf19c3 6019d52 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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)
@pytest.mark.parametrize("paffinity", [2.0, 3.3010299957, 6.0, 7.5850267, 9.0])
def test_round_trip(paffinity):
assert micromolar_to_paffinity(paffinity_to_micromolar(paffinity)) == pytest.approx(
paffinity
)
@pytest.mark.parametrize("bad", [0.0, -1.0, math.inf, math.nan])
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)
|