def test_yarn_from_concat_b(self) -> None: f1 = ff.parse('s(4,2)').rename('f1') f2 = ff.parse('s(4,5)').rename('f2') f3 = ff.parse('s(2,2)').rename('f3') f4 = ff.parse('s(2,8)').rename('f4') f5 = ff.parse('s(4,4)').rename('f5') f6 = ff.parse('s(6,4)').rename('f6') b1 = Bus.from_frames((f1, f2, f3)) b2 = Bus.from_frames((f4, f5, f6)) with temp_file('.zip') as fp1, temp_file('.zip') as fp2: b1.to_zip_pickle(fp1) b2.to_zip_pickle(fp2) bus_a = Bus.from_zip_pickle(fp1, max_persist=1).rename('a') bus_b = Bus.from_zip_pickle(fp2, max_persist=1).rename('b') y1 = Yarn.from_concat((Yarn.from_buses((bus_a, ), retain_labels=True), Yarn.from_buses((bus_b, ), retain_labels=True))) y2 = Yarn.from_concat((y1, y1), index=IndexAutoFactory) self.assertEqual(y2[3].shape, (2, 8)) self.assertEqual(y2[0].shape, (4, 2)) self.assertEqual(y2[5].shape, (6, 4)) y3 = y2.iloc[4:] self.assertEqual(y3.shape, (8, ))
def test_yarn_from_concat_a(self) -> None: f1 = ff.parse('s(4,4)|v(int,float)').rename('f1') f2 = ff.parse('s(4,4)|v(str)').rename('f2') f3 = ff.parse('s(4,4)|v(bool)').rename('f3') b1 = Bus.from_frames((f1, f2, f3), name='a') f4 = ff.parse('s(4,4)|v(int,float)').rename('f4') f5 = ff.parse('s(4,4)|v(str)').rename('f5') b2 = Bus.from_frames((f4, f5), name='b') f6 = ff.parse('s(2,4)|v(int,float)').rename('f6') f7 = ff.parse('s(4,2)|v(str)').rename('f7') b3 = Bus.from_frames((f6, f7), name='c') y1 = Yarn.from_concat((Yarn.from_buses((b1,), retain_labels=True), Yarn.from_buses((b2, b3), retain_labels=True))) self.assertEqual(y1.shape, (7,)) self.assertEqual(y1.index.values.tolist(), [['a', 'f1'], ['a', 'f2'], ['a', 'f3'], ['b', 'f4'], ['b', 'f5'], ['c', 'f6'], ['c', 'f7']] )
def test_yarn_from_concat_c(self) -> None: f1 = ff.parse('s(4,2)').rename('f1') f2 = ff.parse('s(4,5)').rename('f2') with self.assertRaises(NotImplementedError): Yarn.from_concat((f1, f2))