Skip to content
Merged
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
2 changes: 1 addition & 1 deletion include/spark_dsg/node_symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class NodeSymbol {
[[deprecated("use str() instead")]] std::string getLabel() const;

//! get a string representation of the symbol
std::string str() const;
std::string str(bool literal = false) const;

/**
* @brief output node symbol information
Expand Down
2 changes: 1 addition & 1 deletion python/bindings/src/spark_dsg_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ PYBIND11_MODULE(_dsg_bindings, module) {
"value",
[](const NodeSymbol& symbol) { return static_cast<NodeId>(symbol); },
nullptr)
.def("__repr__", &NodeSymbol::str)
.def("__repr__", [](const NodeSymbol& ns) { return ns.str(false); })
.def("__hash__",
[](const NodeSymbol& symbol) { return static_cast<NodeId>(symbol); })
.def(pybind11::self == pybind11::self)
Expand Down
7 changes: 6 additions & 1 deletion src/node_symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ NodeSymbol NodeSymbol::operator++(int) {
return old;
}

std::string NodeSymbol::str() const {
std::string NodeSymbol::str(bool literal) const {
if (literal) {
const auto idx = std::to_string(value_.symbol.index);
return std::isalpha(value_.symbol.key) ? value_.symbol.key + idx : idx;
}

std::stringstream ss;
ss << *this;
return ss.str();
Expand Down