Skip to content

Conversation

@jajberni
Copy link

@jajberni jajberni commented Dec 1, 2025

This PR adds a function to load custom tree definitions from XML files, as currently available in the core Helios.

from pyhelios import Context, WeberPennTree
context = Context()
wpt = WeberPennTree(context)

wpt.loadXML('/tmp/custom-tree.xml')

new_tree_id = wpt.buildTreeFromName("CustomTree")

Unit tests have been added to add coverage to the new functionality.

Note that an absolute path is required for the XML. I had to implement the new function buildTreeFromName because buildTree only accepts WPTType. It would be nicer to generalise the tree names and add new tree definitions to the hard-coded trees, so that loading an XML file adds new names. A function like getAvailableTreeTypes could provide all the available names, but it would require adding a new public method into WeberPennTree.h and WeberPennTree.cpp.

E.g,:

std::vector<std::string> WeberPennTree::getAvailableTreeTypes() {
    std::vector<std::string> treeNames;
    for (const auto& tree : trees_library) {
        treeNames.push_back(tree.first);
    }
    return treeNames;
}

Then it would be possible to expose this function in Python and avoid hardcoding WPTType.

@bnbailey-psl bnbailey-psl force-pushed the master branch 3 times, most recently from e8cf2c5 to 4ab4f1c Compare December 1, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant