def test_merge_outlines(metadata, dataframe, out_dir): metadata.loadSingle(os.path.join(out_dir, 'test.csv'), 'default', int) outlines = pd.DataFrame( { 'Metadata_Plate': __rand_array(), 'Metadata_Well': __rand_array(), 'Metadata_Site': __rand_array() }, dtype=int) metadata.mergeOutlines(outlines) merged = pd.merge(metadata.data, outlines, on=["Metadata_Plate", "Metadata_Well", "Metadata_Site"]) pd.testing.assert_frame_equal(metadata.data, merged)
def test_filter_records(metadata, dataframe, out_dir): metadata.loadSingle(os.path.join(out_dir, 'test.csv'), 'default', int) rule = lambda data: map(lambda row: any(row % 2 == 0), data.values) metadata.filterRecords(rule) filtered = dataframe.loc[rule(dataframe), :] pd.testing.assert_frame_equal(metadata.data, filtered)
def test_load_single(metadata, dataframe, out_dir): filename = os.path.join(out_dir, 'test.csv') assert os.path.exists(filename) metadata.loadSingle(filename, 'default', int) pd.testing.assert_frame_equal(metadata.data, dataframe)
def test_split_metadata(metadata, dataframe, out_dir): metadata.loadSingle(os.path.join(out_dir, 'test.csv'), 'default', int) train_rule = lambda data: data['Metadata_Plate'] < 50 val_rule = lambda data: data['Metadata_Plate'] >= 50 metadata.splitMetadata(train_rule, val_rule) assert len(metadata.train) + len(metadata.val) == len(metadata.data)