Skip to content

Commit 4f58e0c

Browse files
committed
from_object
1 parent b911dc8 commit 4f58e0c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/compas/datastructures/tree/hashtree.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from compas.datastructures import Tree
22
from compas.datastructures import TreeNode
3+
from compas.data import Data
34
from compas.data import json_dumps
45
import hashlib
56

@@ -165,13 +166,10 @@ def from_dict(cls, data_dict):
165166

166167
@classmethod
167168
def from_object(cls, obj):
168-
"""Construct a HashTree from a COMPAS object."""
169-
raise NotImplementedError
170-
171-
@classmethod
172-
def from_scene(cls, scene):
173-
"""Construct a HashTree from a COMPAS scene."""
174-
raise NotImplementedError
169+
"""Construct a HashTree from a COMPAS data object."""
170+
if not isinstance(obj, Data):
171+
raise TypeError("The object must be a COMPAS data object.")
172+
return cls.from_dict(obj.data)
175173

176174
def node_signature(self, node, parent_path=""):
177175
"""Compute the SHA256 signature of a node. The computed nodes are cached in `self.signatures` dictionary.

0 commit comments

Comments
 (0)