Open florisvb opened 8 years ago
problem arises in the deepcopy command (ln 702).
https://docs.python.org/2/library/copy.html
A deep copy constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original. Two problems often exist with deep copy operations that don’t exist with shallow copy operations: Recursive objects (compound objects that, directly or indirectly, contain a reference to themselves) may cause a recursive loop.
Using a standard (shallow) copy allows the layout to be loaded, and assigns all the correct figure / axis objects, but then produces an error in make_mplfigures().
AttributeError Traceback (most recent call last)
Possible hacky solution: make it possible to clear the target layers BEFORE make_group_tree is called. This might require saving an intermediate svg file, which is then reloaded?
Attached files include a layout which can be opened (layout = figurefirst.svg_to_axes.FigureLayout('figure1_output_test2_works.svg') with figurefirst, and one that is the output from my script, which produces the runtime error (layout = figurefirst.svg_to_axes.FigureLayout('figure1_output_test2.svg'). Deleting the layers added by figurefirst eliminates the runtime error.
Note: change .txt to .svg
figure1_output_test2_works.txt figure1_output_test2.txt
Error:
File "/home/caveman/Documents/src/python/ANALYSIS/lib/python2.7/site-packages/figurefirst/svg_to_axes.py", line 541, in __init__ figuretree,grouptree,leafs,svgitemtree = self.make_group_tree() File "/home/caveman/Documents/src/python/ANALYSIS/lib/python2.7/site-packages/figurefirst/svg_to_axes.py", line 702, in make_group_tree newv = copy.deepcopy(figuretree[l.template_source]) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo)