def _gen_lines()

in community-artifacts/Deep-learning/Utilities/madlib_image_loader.py [0:0]


    def _gen_lines(self, data):
        def f(x):
            x = str(x.tolist())
            return x.replace('[','{').replace(']','}')

        for i, row in enumerate(data):
            if len(row) == 3:
                x, y, image_name = row
                if not self.from_disk and y.ndim > 1:
                    y = f(y)
                yield '{0}|{1}|{2}\n'.format(f(x), y, image_name)
            elif len(row) == 2:
                x, y = row
                if not self.from_disk and y.ndim > 1:
                    y = f(y)
                yield '{0}|{1}\n'.format(f(x), y)
            else:
                raise RuntimeError("Cannot write invalid row to table:\n{0}"\
                    .format(row))