Skip to content

Commit 4b2562f

Browse files
authored
Merge pull request #1458 from compas-dev/group
Group
2 parents 8496686 + 70e0163 commit 4b2562f

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
* Changed `SceneObject.frame` to read-only result of `Frame.from_transformation(SceneObject.worldtransformation)`, representing the local coordinate system of the scene object in world coordinates.
2222
* Changed `SceneObject.worldtransformation` to the multiplication of all transformations from the scene object to the root of the scene tree, there will no longer be an additional transformation in relation to the object's frame.
2323
* Fixed call to `astar_shortest_path` in `Graph.shortest_path`.
24+
* Fixed a bug when printing an empty `Tree`.
25+
* Fixed a bug in `Group` for IronPython where the decoding declaration was missing.
26+
* Fixed a bug where a `Group` without name could not be added to the scene.
2427

2528
### Removed
2629

src/compas/datastructures/tree/tree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ def traverse(node, hierarchy, prefix="", last=True, depth=0):
465465
for i, child in enumerate(node.children):
466466
traverse(child, hierarchy, prefix, i == len(node.children) - 1, depth + 1)
467467

468-
traverse(self.root, hierarchy)
468+
if self.root:
469+
traverse(self.root, hierarchy)
469470

470471
return "\n".join(hierarchy)
471472

src/compas/scene/group.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from .sceneobject import SceneObject
23

34

src/compas/scene/sceneobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(
104104
if item and not isinstance(item, Data):
105105
raise ValueError("The item assigned to this scene object should be a data object: {}".format(type(item)))
106106

107-
name = name or item.name
107+
name = name or getattr(item, "name", None)
108108
super(SceneObject, self).__init__(name=name, **kwargs)
109109
# the scene object needs to store the context
110110
# because it has no access to the tree and/or the scene before it is added

tests/compas/datastructures/test_tree.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ def test_tree_initialization():
5151
assert tree.root is None
5252

5353

54+
def test_empty_tree():
55+
tree = Tree()
56+
assert tree.root is None
57+
assert len(list(tree.nodes)) == 0
58+
assert len(list(tree.leaves)) == 0
59+
assert list(tree.traverse()) == []
60+
assert tree.get_hierarchy_string() == ""
61+
62+
5463
# =============================================================================
5564
# TreeNode Properties
5665
# =============================================================================

0 commit comments

Comments
 (0)