diff --git a/weldx/tests/transformations/test_cs_manager.py b/weldx/tests/transformations/test_cs_manager.py index 34276b8e8..302dbb563 100644 --- a/weldx/tests/transformations/test_cs_manager.py +++ b/weldx/tests/transformations/test_cs_manager.py @@ -737,6 +737,18 @@ def test_comparison_wrong_type(): assert (csm != 4) is True +def test_comparison_data(): + csm1 = tf.CoordinateSystemManager("root", "csm") + csm2 = tf.CoordinateSystemManager("root", "csm") + data = np.arange(12).reshape((4, 3)) + csm1.assign_data(data, data_name="foo", reference_system="root") + csm2.assign_data(data, data_name="foo", reference_system="root") + + assert csm1 == csm2 + csm2.assign_data(data, data_name="bar", reference_system="root") + assert csm1 != csm2 + + # test_time_union ---------------------------------------------------------------------- diff --git a/weldx/transformations/cs_manager.py b/weldx/transformations/cs_manager.py index e37abccbd..1ae944e2f 100644 --- a/weldx/transformations/cs_manager.py +++ b/weldx/transformations/cs_manager.py @@ -149,7 +149,6 @@ def __repr__(self): def __eq__(self, other: Any): """Test equality of CSM instances.""" - # todo: also check data -> add tests if not isinstance(other, self.__class__): return False @@ -175,17 +174,19 @@ def __eq__(self, other: Any): for node in graph_0.nodes: if node not in graph_1.nodes: return False + n0 = graph_0.nodes[node] + n1 = graph_1.nodes[node] + if not util.compare_nested(n0, n1): + return False # check edges for edge in graph_0.edges: if edge not in graph_1.edges: return False - # check coordinate systems - for edge in graph_0.edges: - lcs_0 = self.graph.edges[(edge[0], edge[1])]["transformation"] - lcs_1 = other.graph.edges[(edge[0], edge[1])]["transformation"] - if lcs_0 != lcs_1: + e0 = graph_0.edges[edge] + e1 = graph_1.edges[edge] + if not util.compare_nested(e0, e1): return False return True