Closed digicosmos86 closed 1 month ago
Hi, Paul
After updated HSSM 0.2.3, I still can not successfully using graph(). When I run the code simple_ddm_model.graph()
, the following error occur.
[890](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:890) """Produce a graphviz Digraph from a built HSSM model.
[891](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:891)
[892](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:892) Requires graphviz, which may be installed most easily with `conda install -c
(...)
[924](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:924) Credit for the code goes to Bambi developers.
[925](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:925) """
[926](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:926) self.model._check_built()
[928](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:928) graphviz = HSSMModelGraph(
[929](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:929) model=self.pymc_model, parent=self._parent_param
--> [930](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:930) ).make_graph(formatting=formatting, response_str=self.response_str)
[932](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:932) width, height = (None, None) if figsize is None else figsize
[934](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/hssm.py:934) if name is not None:
File ~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/utils.py:205, in HSSMModelGraph.make_graph(self, var_names, formatting, response_str)
[203](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/utils.py:203) raise e
[204](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/utils.py:204) graph = graphviz.Digraph(self.model.name)
--> [205](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/utils.py:205) for plate_label, all_var_names in self.get_plates(var_names).items():
[206](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/utils.py:206) if plate_label:
[207](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/utils.py:207) # must be preceded by 'cluster' to get a box around it
[208](https://file+.vscode-resource.vscode-cdn.net/Users/yuanbo/Work%20and%20Study/Python_projects/HSSM/~/miniforge3/envs/hssm/lib/python3.11/site-packages/hssm/utils.py:208) with graph.subgraph(name="cluster" + plate_label) as sub:
AttributeError: 'list' object has no attribute 'items'
There might be some corner cases that we did not think of. However, this should be fixed via Bambi v0.14.0 and the graph should look cleaner. Please stay tuned.
This is fixed via #521
One good resource for update is https://github.com/bambinos/bambi/pull/804