Remove .roots()
parent
f48e94fa25
commit
91924d92db
|
@ -227,20 +227,9 @@
|
||||||
"bayes_tree.print()"
|
"bayes_tree.print()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"id": "bayestree_props_md"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"## Properties and Access\n",
|
|
||||||
"\n",
|
|
||||||
"A `BayesTree` allows access to its root cliques and provides a way to look up the clique containing a specific variable."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 5,
|
"execution_count": 11,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"colab": {
|
"colab": {
|
||||||
"base_uri": "https://localhost:8080/"
|
"base_uri": "https://localhost:8080/"
|
||||||
|
@ -255,35 +244,10 @@
|
||||||
"text": [
|
"text": [
|
||||||
"BayesTree number of cliques: 2\n"
|
"BayesTree number of cliques: 2\n"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"ename": "AttributeError",
|
|
||||||
"evalue": "'gtsam.gtsam.GaussianBayesTree' object has no attribute 'roots'",
|
|
||||||
"output_type": "error",
|
|
||||||
"traceback": [
|
|
||||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
|
||||||
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
|
||||||
"Cell \u001b[1;32mIn[5], line 4\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mBayesTree number of cliques: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mbayes_tree\u001b[38;5;241m.\u001b[39msize()\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m# Access roots\u001b[39;00m\n\u001b[1;32m----> 4\u001b[0m roots \u001b[38;5;241m=\u001b[39m \u001b[43mbayes_tree\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mroots\u001b[49m()\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNumber of roots: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(roots)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 6\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m roots:\n\u001b[0;32m 7\u001b[0m \u001b[38;5;66;03m# Access the conditional associated with the first root clique\u001b[39;00m\n",
|
|
||||||
"\u001b[1;31mAttributeError\u001b[0m: 'gtsam.gtsam.GaussianBayesTree' object has no attribute 'roots'"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"print(f\"BayesTree number of cliques: {bayes_tree.size()}\")\n",
|
"print(f\"BayesTree number of cliques: {bayes_tree.size()}\")"
|
||||||
"\n",
|
|
||||||
"# Access roots\n",
|
|
||||||
"roots = bayes_tree.roots()\n",
|
|
||||||
"print(f\"Number of roots: {len(roots)}\")\n",
|
|
||||||
"if roots:\n",
|
|
||||||
" # Access the conditional associated with the first root clique\n",
|
|
||||||
" root_conditional = roots[0].conditional()\n",
|
|
||||||
" print(f\"Root clique 0 conditional frontals: {root_conditional.frontals()}\")\n",
|
|
||||||
"\n",
|
|
||||||
"# Find the clique containing a specific variable\n",
|
|
||||||
"clique_x1 = bayes_tree.clique(X(1))\n",
|
|
||||||
"# clique_x1 is a shared pointer to the clique (e.g., GaussianBayesTreeClique)\n",
|
|
||||||
"print(f\"\\nClique containing x1 ({X(1)}):\")\n",
|
|
||||||
"clique_x1.print() # Print the clique itself"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue