renamed Document.flatten_all_paths to flattened_paths

pull/114/head
Andy Port 2020-06-23 20:53:54 -07:00
parent d673176347
commit 445899b2eb
2 changed files with 8 additions and 9 deletions

View File

@ -15,7 +15,7 @@ Example:
>> from svgpathtools import *
>> doc = Document('my_file.html')
>> for path in doc.flatten_all_paths():
>> for path in doc.flattened_paths():
>> # Do something with the transformed Path object.
>> foo(path)
>> # Inspect the raw SVG element, e.g. change its attributes
@ -196,7 +196,7 @@ def flatten_group(group_to_flatten, root, recursive=True,
for group in route:
# Add each group from the root to the parent of the desired group
# to the list of groups that we should traverse. This makes sure
# that flatten_all_paths will not stop before reaching the desired
# that flattened_paths will not stop before reaching the desired
# group.
desired_groups.add(id(group))
for key in path_conversions.keys():
@ -249,11 +249,10 @@ class Document:
self.root = self.tree.getroot()
def flatten_all_paths(self, group_filter=lambda x: True,
path_filter=lambda x: True,
path_conversions=CONVERSIONS):
def flattened_paths(self, group_filter=lambda x: True,
path_filter=lambda x: True, path_conversions=CONVERSIONS):
"""Forward the tree of this document into the more general
flatten_all_paths function and return the result."""
flattened_paths function and return the result."""
return flatten_all_paths(self.tree.getroot(), group_filter,
path_filter, path_conversions)

View File

@ -26,7 +26,7 @@ class TestGroups(unittest.TestCase):
# end point relative to the start point
# * name is the path name (value of the test:name attribute in
# the SVG document)
# * paths is the output of doc.flatten_all_paths()
# * paths is the output of doc.flattened_paths()
v_s_vals.append(1.0)
v_e_relative_vals.append(0.0)
v_s = np.array(v_s_vals)
@ -38,7 +38,7 @@ class TestGroups(unittest.TestCase):
self.check_values(tf.dot(v_e), actual.path.end)
def test_group_flatten(self):
# Test the Document.flatten_all_paths() function against the
# Test the Document.flattened_paths() function against the
# groups.svg test file.
# There are 12 paths in that file, with various levels of being
# nested inside of group transforms.
@ -48,7 +48,7 @@ class TestGroups(unittest.TestCase):
# that are specified by the SVG standard.
doc = Document(join(dirname(__file__), 'groups.svg'))
result = doc.flatten_all_paths()
result = doc.flattened_paths()
self.assertEqual(12, len(result))
tf_matrix_group = np.array([[1.5, 0.0, -40.0],