|
|
|
@ -15,6 +15,99 @@ def test_split_data_frame(data_frame_with_params):
@@ -15,6 +15,99 @@ def test_split_data_frame(data_frame_with_params):
|
|
|
|
|
assert set(value_df["Well.Row"].unique()) == {key} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
|
|
"value,expected", |
|
|
|
|
[ |
|
|
|
|
[[1, 2], True], |
|
|
|
|
[(1, 2), True], |
|
|
|
|
[{1, 2}, False], |
|
|
|
|
[{1: 2}, False], |
|
|
|
|
["1, 2", False], |
|
|
|
|
[None, False], |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
def test_is_list_or_tuple(value, expected): |
|
|
|
|
from sensospot_data.utils import _is_list_or_tuple |
|
|
|
|
|
|
|
|
|
result = _is_list_or_tuple(value) |
|
|
|
|
|
|
|
|
|
assert result is expected |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
|
|
"value,expected", |
|
|
|
|
[ |
|
|
|
|
[1, True], |
|
|
|
|
[1.2, True], |
|
|
|
|
[{1, 2}, False], |
|
|
|
|
[{1: 2}, False], |
|
|
|
|
["1", False], |
|
|
|
|
[None, False], |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
def test_is_numerical(value, expected): |
|
|
|
|
from sensospot_data.utils import _is_numerical |
|
|
|
|
|
|
|
|
|
result = _is_numerical(value) |
|
|
|
|
|
|
|
|
|
assert result is expected |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_valid_exposure_map_entry_ok(): |
|
|
|
|
from sensospot_data.utils import _check_valid_exposure_map_entry |
|
|
|
|
|
|
|
|
|
result = _check_valid_exposure_map_entry((2, 1)) |
|
|
|
|
|
|
|
|
|
assert result is None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
|
|
"value", [[], [1], (1, 2, 3), {"a": 1, "b": 2}, ("A", "B")] |
|
|
|
|
) |
|
|
|
|
def test_check_valid_exposure_map_entry_raises_error(value): |
|
|
|
|
from sensospot_data.utils import _check_valid_exposure_map_entry |
|
|
|
|
|
|
|
|
|
with pytest.raises(ValueError): |
|
|
|
|
_check_valid_exposure_map_entry(value) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_exposure_map_ok(exposure_df): |
|
|
|
|
from sensospot_data.utils import _check_exposure_map |
|
|
|
|
|
|
|
|
|
exposure_map = {1: ("A", 10), 2: ("B", 20), 3: ("C", 30)} |
|
|
|
|
|
|
|
|
|
result = _check_exposure_map(exposure_df, exposure_map) |
|
|
|
|
|
|
|
|
|
assert result is None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_exposure_map_wrong_type(exposure_df): |
|
|
|
|
from sensospot_data.utils import _check_exposure_map |
|
|
|
|
|
|
|
|
|
exposure_map = [] |
|
|
|
|
|
|
|
|
|
with pytest.raises(ValueError): |
|
|
|
|
_check_exposure_map(exposure_df, exposure_map) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_exposure_map_wrong_ids(exposure_df): |
|
|
|
|
from sensospot_data.utils import _check_exposure_map |
|
|
|
|
|
|
|
|
|
exposure_map = {1: ("A", 10), 2: ("B", 20), 4: ("D", 40)} |
|
|
|
|
|
|
|
|
|
with pytest.raises(ValueError): |
|
|
|
|
_check_exposure_map(exposure_df, exposure_map) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_exposure_map_invalid_entries(exposure_df): |
|
|
|
|
from sensospot_data.utils import _check_exposure_map |
|
|
|
|
|
|
|
|
|
exposure_map = {1: ("A", 10), 2: ("B", 20), 3: "ERROR"} |
|
|
|
|
|
|
|
|
|
with pytest.raises(ValueError): |
|
|
|
|
_check_exposure_map(exposure_df, exposure_map) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_infer_exposure_from_parameters(data_frame_with_params): |
|
|
|
|
from sensospot_data.utils import _set_exposure_data_from_parameters |
|
|
|
|
|
|
|
|
@ -62,11 +155,9 @@ def test_apply_exposure_map_raises_error(data_frame_with_params):
@@ -62,11 +155,9 @@ def test_apply_exposure_map_raises_error(data_frame_with_params):
|
|
|
|
|
"X": ExposureSetting("Cy5", 150), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
with pytest.raises(ValueError) as excinfo: |
|
|
|
|
with pytest.raises(ValueError): |
|
|
|
|
apply_exposure_map(data_frame_with_params, exposure_map) |
|
|
|
|
|
|
|
|
|
assert str(excinfo.value).startswith("Exposure Map differs") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_apply_exposure_map_from_parameters(data_frame_with_params): |
|
|
|
|
from sensospot_data.utils import apply_exposure_map |
|
|
|
|