Skip to content

Commit 6aee642

Browse files
committed
move print_tree() to helpers
1 parent 82a114f commit 6aee642

File tree

3 files changed

+22
-58
lines changed

3 files changed

+22
-58
lines changed

test/helpers.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
#
33
import matplotlib2tikz
44

5+
import imagehash
6+
import matplotlib
7+
import matplotlib.pyplot as plt
58
import os
9+
from PIL import Image
610
import shutil
7-
import tempfile
811
import subprocess
9-
from PIL import Image
10-
import imagehash
11-
from matplotlib import pyplot as plt
12+
import tempfile
1213

1314

1415
def compute_phash(fig):
@@ -145,3 +146,16 @@ def assert_phash(fig, reference_phash):
145146
assert reference_phash == phash
146147

147148
return
149+
150+
151+
def print_tree(obj, indent=''):
152+
'''Recursively prints the tree structure of the matplotlib object.
153+
'''
154+
if isinstance(obj, matplotlib.text.Text):
155+
print(indent, type(obj).__name__, '("%s")' % obj.get_text())
156+
else:
157+
print(indent, type(obj).__name__)
158+
159+
for child in obj.get_children():
160+
print_tree(child, indent + ' ')
161+
return

test/test_viridis.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ def plot():
2020

2121
def test():
2222
helpers.assert_phash(plot(), 'fd7e03fc03bc0381')
23+
24+
25+
if __name__ == '__main__':
26+
helpers.print_tree(plot())

test/tree

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)