Skip to content

Group #1458

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Apr 16, 2025
Merged

Group #1458

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* 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.
* 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.
* Fixed call to `astar_shortest_path` in `Graph.shortest_path`.
* Fixed a bug when printing an empty `Tree`.
* Fixed a bug in `Group` for IronPython where the decoding declaration was missing.
* Fixed a bug where a `Group` without name could not be added to the scene.

### Removed

Expand Down
3 changes: 2 additions & 1 deletion src/compas/datastructures/tree/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@
for i, child in enumerate(node.children):
traverse(child, hierarchy, prefix, i == len(node.children) - 1, depth + 1)

traverse(self.root, hierarchy)
if self.root:
traverse(self.root, hierarchy)

Check warning on line 469 in src/compas/datastructures/tree/tree.py

View check run for this annotation

Codecov / codecov/patch

src/compas/datastructures/tree/tree.py#L469

Added line #L469 was not covered by tests

return "\n".join(hierarchy)

Expand Down
1 change: 1 addition & 0 deletions src/compas/scene/group.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from .sceneobject import SceneObject


Expand Down
2 changes: 1 addition & 1 deletion src/compas/scene/sceneobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(
if item and not isinstance(item, Data):
raise ValueError("The item assigned to this scene object should be a data object: {}".format(type(item)))

name = name or item.name
name = name or getattr(item, "name", None)
super(SceneObject, self).__init__(name=name, **kwargs)
# the scene object needs to store the context
# because it has no access to the tree and/or the scene before it is added
Expand Down
9 changes: 9 additions & 0 deletions tests/compas/datastructures/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ def test_tree_initialization():
assert tree.root is None


def test_empty_tree():
tree = Tree()
assert tree.root is None
assert len(list(tree.nodes)) == 0
assert len(list(tree.leaves)) == 0
assert list(tree.traverse()) == []
assert tree.get_hierarchy_string() == ""


# =============================================================================
# TreeNode Properties
# =============================================================================
Expand Down
Loading