Skip to content

Commit

Permalink
test labelspace bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhhughes committed Jan 22, 2025
1 parent dfda111 commit 5bfee58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/bindings/src/spark_dsg_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ PYBIND11_MODULE(_dsg_bindings, module) {
},
"node"_a,
"unknown_name"_a = "UNKNOWN")
.def("__bool__", [](const Labelspace& labelspace) { return static_cast<bool>(labelspace); })
.def_property_readonly("labels_to_names", &Labelspace::labels_to_names)
.def_property_readonly("names_to_labels", &Labelspace::names_to_labels);

Expand Down
13 changes: 13 additions & 0 deletions python/tests/test_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,16 @@ def test_attribute_metadata(tmp_path):
G_new = dsg.DynamicSceneGraph.load(graph_path)
new_attrs = G_new.get_node(dsg.NodeSymbol("O", 1)).attributes
assert new_attrs.metadata.get() == {"test": {"a": 6, "b": 42.0, "c": "hello"}}


def test_labelspace():
labelspace = dsg.Labelspace({0: "wall", 1: "floor", 2: "ceiling", 4: "desk"})
assert labelspace.get_category(1) == "floor"
assert labelspace.get_category(3) is None
assert labelspace.get_label("wall") == 0
assert labelspace.get_label("lamp") is None

G = dsg.DynamicSceneGraph()
G.set_labelspace(labelspace, 0, 1)
assert not G.get_labelspace(0, 0)
assert G.get_labelspace(0, 1).labels_to_names == labelspace.labels_to_names

0 comments on commit 5bfee58

Please sign in to comment.