diff --git a/tests/data/applications/valuetable.csv b/tests/data/applications/valuetable.csv new file mode 100644 index 0000000..148f406 --- /dev/null +++ b/tests/data/applications/valuetable.csv @@ -0,0 +1,26 @@ +,factor_1,factor_2,factor_3,complement,final_volume +units,uL,uL,uL,WATER,3 +unit_1,0,0,0,, +unit_2,1,0,0,, +unit_3,0,1,0,, +unit_4,0,0,1,, +unit_5,1,1,0,, +unit_6,1,0,1,, +unit_7,0,1,1,, +unit_8,1,1,1,, +unit_9,0,0,0,, +unit_10,1,0,0,, +unit_11,0,1,0,, +unit_12,0,0,1,, +unit_13,1,1,0,, +unit_14,1,0,1,, +unit_15,0,1,1,, +unit_16,1,1,1,, +unit_17,0,0,0,, +unit_18,1,0,0,, +unit_19,0,1,0,, +unit_20,0,0,1,, +unit_21,1,1,0,, +unit_22,1,0,1,, +unit_23,0,1,1,, +unit_24,1,1,1,, diff --git a/tests/data/applications/volumetable_out.csv b/tests/data/applications/volumetable_out.csv new file mode 100644 index 0000000..3e853e9 --- /dev/null +++ b/tests/data/applications/volumetable_out.csv @@ -0,0 +1,25 @@ +,factor_1,factor_2,factor_3,complement +unit_1,0.0,0.0,0.0,3.0 +unit_2,1.0,0.0,0.0,2.0 +unit_3,0.0,1.0,0.0,2.0 +unit_4,0.0,0.0,1.0,2.0 +unit_5,1.0,1.0,0.0,1.0 +unit_6,1.0,0.0,1.0,1.0 +unit_7,0.0,1.0,1.0,1.0 +unit_8,1.0,1.0,1.0,0.0 +unit_9,0.0,0.0,0.0,3.0 +unit_10,1.0,0.0,0.0,2.0 +unit_11,0.0,1.0,0.0,2.0 +unit_12,0.0,0.0,1.0,2.0 +unit_13,1.0,1.0,0.0,1.0 +unit_14,1.0,0.0,1.0,1.0 +unit_15,0.0,1.0,1.0,1.0 +unit_16,1.0,1.0,1.0,0.0 +unit_17,0.0,0.0,0.0,3.0 +unit_18,1.0,0.0,0.0,2.0 +unit_19,0.0,1.0,0.0,2.0 +unit_20,0.0,0.0,1.0,2.0 +unit_21,1.0,1.0,0.0,1.0 +unit_22,1.0,0.0,1.0,1.0 +unit_23,0.0,1.0,1.0,1.0 +unit_24,1.0,1.0,1.0,0.0 diff --git a/tests/test_doe.py b/tests/test_doe.py index f69042e..07722b5 100644 --- a/tests/test_doe.py +++ b/tests/test_doe.py @@ -1,23 +1,47 @@ +import filecmp import os import pandas from plateo.applications.doe import ( + import_valuetable_from_csv, + convert_valuetable_to_volumetable, convert_volumetable_to_actiontable, import_volumetable_from_csv_file, ) from plateo.parsers import plate_from_content_spreadsheet from plateo.containers import Plate96 +valuetable_path = os.path.join("tests", "data", "applications", "valuetable.csv") +volumetable_out_path = os.path.join( + "tests", "data", "applications", "volumetable_out.csv" +) + volumetable_path = os.path.join("tests", "data", "applications", "volumetable.csv") source_plate_path = os.path.join("tests", "data", "applications", "Source_Plate.xlsx") +def test_convert_valuetable_to_volumetable(tmpdir): + valuetable = import_valuetable_from_csv(valuetable_path) + volumetable = convert_valuetable_to_volumetable(valuetable) + volumetable.to_csv( + path_or_buf=os.path.join(tmpdir, "volumetable_out.csv"), + sep=",", + columns=None, + header=True, + index=True, + ) + assert filecmp.cmp( + os.path.join(volumetable_out_path), + os.path.join(tmpdir, "volumetable_out.csv"), + ) + + def test_volumetable_from_csv_file(): - assert type(import_volumetable_from_csv_file(volumetable_path)) == pandas.DataFrame + assert type(import_volumetable_from_csv_file(volumetable_path)) is pandas.DataFrame -def test_dataframe_from_volume_table(): +def test_convert_volumetable_to_actiontable(): volumetable = import_volumetable_from_csv_file(volumetable_path) source_plate = plate_from_content_spreadsheet(source_plate_path) dest_plate = Plate96(name="dest") @@ -25,4 +49,4 @@ def test_dataframe_from_volume_table(): volumetable=volumetable, source_plate=source_plate, dest_plate=dest_plate ) - assert type(dataframe) == pandas.DataFrame + assert type(dataframe) is pandas.DataFrame