Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix graphing after bambi 0.14 is released #491

Closed
digicosmos86 opened this issue Jul 10, 2024 · 3 comments
Closed

Fix graphing after bambi 0.14 is released #491

digicosmos86 opened this issue Jul 10, 2024 · 3 comments
Assignees

Comments

@digicosmos86
Copy link
Collaborator

One good resource for update is bambinos/bambi#804

@digicosmos86 digicosmos86 self-assigned this Jul 10, 2024
@YuanboBQ
Copy link

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'

@digicosmos86
Copy link
Collaborator Author

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.

@digicosmos86
Copy link
Collaborator Author

This is fixed via #521

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

No branches or pull requests

2 participants