You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.2 KiB
84 lines
2.2 KiB
1 year ago
|
import pandas as pd
|
||
|
import pytest
|
||
|
|
||
|
|
||
|
def _generate_example_data(exposures):
|
||
|
values = [(i, i * 10, i * 100) for i in range(1, exposures + 1)]
|
||
|
columns = ["Exposure.Id", "Bkg.Median", "Spot.Median"]
|
||
|
|
||
|
return pd.DataFrame(values, columns=columns)
|
||
|
|
||
|
|
||
|
@pytest.fixture()
|
||
|
def classic_example_data():
|
||
|
return _generate_example_data(4)
|
||
|
|
||
|
|
||
|
@pytest.fixture()
|
||
|
def regression_example_data():
|
||
|
return _generate_example_data(6)
|
||
|
|
||
|
|
||
|
def test_add_exposure_info_classic(classic_example_data):
|
||
|
from conda_helpers.calibration import add_exposure_info
|
||
|
|
||
|
result = add_exposure_info(classic_example_data)
|
||
|
|
||
|
assert list(result["Exposure.Channel"]) == ["Cy3"] * 2 + ["Cy5"] * 2
|
||
|
assert list(result["Exposure.Time"]) == [100, 10, 60, 6]
|
||
|
|
||
|
|
||
|
def test_add_exposure_info_regression(regression_example_data):
|
||
|
from conda_helpers.calibration import add_exposure_info
|
||
|
|
||
|
result = add_exposure_info(regression_example_data)
|
||
|
|
||
|
assert list(result["Exposure.Channel"]) == ["Cy3"] * 3 + ["Cy5"] * 3
|
||
|
assert list(result["Exposure.Time"]) == [100, 30, 10, 60, 18, 6]
|
||
|
|
||
|
|
||
|
def test_remove_non_signal_positions():
|
||
|
from conda_helpers.calibration import remove_non_signal_positions
|
||
|
|
||
|
data = pd.DataFrame(range(1, 12), columns=["Pos.Id"])
|
||
|
|
||
|
result = remove_non_signal_positions(data)
|
||
|
|
||
|
assert set(result["Pos.Id"]) == {3, 4, 5, 6, 7, 8}
|
||
|
|
||
|
|
||
|
def test_add_signal_columns(classic_example_data):
|
||
|
from conda_helpers.calibration import add_signal_columns
|
||
|
|
||
|
result = add_signal_columns(classic_example_data)
|
||
|
|
||
|
assert len(result) == 2 * len(classic_example_data)
|
||
|
|
||
|
assert (
|
||
|
list(result["Signal.Source"])
|
||
|
== ["Spot.Median"] * 4 + ["Bkg.Median"] * 4
|
||
|
)
|
||
|
assert list(result["Signal.Intensity"]) == [
|
||
|
100,
|
||
|
200,
|
||
|
300,
|
||
|
400,
|
||
|
10,
|
||
|
20,
|
||
|
30,
|
||
|
40,
|
||
|
]
|
||
|
|
||
|
|
||
|
def test_prepare_calibration_data(classic_example_data):
|
||
|
from conda_helpers.calibration import prepare_calibration_data
|
||
|
|
||
|
classic_example_data["Pos.Id"] = 0
|
||
|
result = prepare_calibration_data(classic_example_data)
|
||
|
|
||
|
assert len(result) == 2 * len(classic_example_data)
|
||
|
assert "Exposure.Channel" in result.columns
|
||
|
assert "Exposure.Time" in result.columns
|
||
|
assert "Signal.Source" in result.columns
|
||
|
assert "Signal.Intensity" in result.columns
|