|
|
|
@ -178,74 +178,3 @@ def test_apply_exposure_map_from_parameters_raises_error(
@@ -178,74 +178,3 @@ def test_apply_exposure_map_from_parameters_raises_error(
|
|
|
|
|
|
|
|
|
|
assert str(excinfo.value).startswith("Exposure Map: measurement") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_aggregate_defaults(normalization_data_frame): |
|
|
|
|
from sensospot_data.utils import aggregate |
|
|
|
|
|
|
|
|
|
normalization_data_frame.rename( |
|
|
|
|
columns={"Exposure.Time": "Exposure.Id"}, inplace=True |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
result = aggregate(normalization_data_frame, "Value", "median") |
|
|
|
|
|
|
|
|
|
assert result.columns == ["Aggregated.Median.Value"] |
|
|
|
|
assert result.index.names == ["Exposure.Id", "Well.Row", "Well.Column"] |
|
|
|
|
assert list(result["Aggregated.Median.Value"]) == [ |
|
|
|
|
3, |
|
|
|
|
30, |
|
|
|
|
300, |
|
|
|
|
2, |
|
|
|
|
20, |
|
|
|
|
200, |
|
|
|
|
1, |
|
|
|
|
10, |
|
|
|
|
100, |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_aggregate_on(normalization_data_frame): |
|
|
|
|
from sensospot_data.utils import aggregate |
|
|
|
|
|
|
|
|
|
result = aggregate( |
|
|
|
|
normalization_data_frame, "Value", "mean", on="Exposure.Time" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
assert result.columns == ["Aggregated.Mean.Value"] |
|
|
|
|
assert result.index.names == ["Exposure.Time"] |
|
|
|
|
assert list(result["Aggregated.Mean.Value"]) == [111, 74, 37] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_aggregate_new_name(normalization_data_frame): |
|
|
|
|
from sensospot_data.utils import aggregate |
|
|
|
|
|
|
|
|
|
result = aggregate( |
|
|
|
|
normalization_data_frame, |
|
|
|
|
"Value", |
|
|
|
|
"mean", |
|
|
|
|
on="Exposure.Time", |
|
|
|
|
new_name="Foo", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
assert result.columns == ["Foo"] |
|
|
|
|
assert result.index.names == ["Exposure.Time"] |
|
|
|
|
assert list(result["Foo"]) == [111, 74, 37] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_aggregate_new_name(normalization_data_frame): |
|
|
|
|
from sensospot_data.utils import add_aggregate |
|
|
|
|
|
|
|
|
|
result = add_aggregate( |
|
|
|
|
normalization_data_frame, |
|
|
|
|
"Value", |
|
|
|
|
"mean", |
|
|
|
|
on="Exposure.Time", |
|
|
|
|
new_name="Foo", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
assert "Foo" in result.columns |
|
|
|
|
assert len(result.columns) == len(normalization_data_frame.columns) + 1 |
|
|
|
|
assert result.index.names == [None] |
|
|
|
|
|
|
|
|
|
for exp, val in [(10, 111), (25, 74), (50, 37)]: |
|
|
|
|
mask = result["Exposure.Time"] == exp |
|
|
|
|
assert result.loc[mask, "Foo"].unique() == [val] |
|
|
|
|