alexandre01 / deepsvg

[NeurIPS 2020] Official code for the paper "DeepSVG: A Hierarchical Generative Network for Vector Graphics Animation". Includes a PyTorch library for deep learning with SVG data.
https://www.reshot.ai
MIT License
981 stars 99 forks source link

Hello, I probably find I bug in 'deepsvg/svglib /svg.py' (merge_group) #39

Open JasonLLLLLLLLLLL opened 11 months ago

JasonLLLLLLLLLLL commented 11 months ago

From the line 250 to 255, there is a func called merge_groups(). the code is as follows:

    def merge_groups(self):
        path_group = self.svg_path_groups[0]
        for path_group in self.svg_path_groups[1:]:
            path_group.svg_paths.extend(path_group.svg_paths)
        self.svg_path_groups = [path_group]
        return self

The variable path_group is being reused in the for loop, which causes confusion to me when I use this function. Inside the loop, path_group.svg_paths.extend(path_group.svg_paths) doesn't make sense because it is trying to extend path_group.svg_paths with itself. This is likely an error. I think it is should be(the **group** is the difference between the two codes):

    def merge_groups(self):
        path_group = self.svg_path_groups[0]
        for **group** in self.svg_path_groups[1:]:
            path_group.svg_paths.extend(**group**.svg_paths)
        self.svg_path_groups = [path_group]
        return self

I use a different variable name (group) in the for loop. Here, path_group.svg_paths.extend(group.svg_paths) correctly extends the svg_paths of the first group. Hopefully, You can notice this message.