Exemplo n.º 1
0
    def test_unflatten_hed(self):
        sr = SidecarMap()
        sidecar1 = {"a_col": {"HED": {"b": "Label/B", "c": "Label/C"}}}
        df1 = sr.flatten_hed(sidecar1)
        undf1 = sr.unflatten_hed(df1)
        self.assertEqual(len(undf1.keys()), 1, "unflatten_hed dictionary should unpack correctly")
        self.assertTrue("a_col" in undf1.keys(), "The correct key is recovered")

        # One value column
        sidecar2 = {"a_col": {"HED": "Label/#"}}
        df2 = sr.flatten_hed(sidecar2)
        undf2 = sr.unflatten_hed(df2)
        self.assertEqual(len(undf2.keys()), 1, "unflatten_hed dictionary should unpack correctly")
        self.assertTrue("a_col" in undf2.keys(), "The correct key is recovered")

        # A combination with other columns
        sidecar3 = {"a_col": {"HED": {"b": "Label/B", "c": "Label/C"}, "d": {"a1": "b1"}},
                    "b_col": {"HED": "Label/#"}, "c_col": {"levels": "e"}}
        df3 = sr.flatten_hed(sidecar3)
        undf3 = sr.unflatten_hed(df3)
        self.assertEqual(len(undf3.keys()), 2, "unflatten_hed dictionary should unpack correctly")
Exemplo n.º 2
0
 def test_unflatten_hed_from_file(self):
     sr = SidecarMap()
     file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              "../data/sternberg/sternberg_flattened.tsv")
     df = get_new_dataframe(file_path)
     sr.unflatten_hed(df)