Fix for "module 'pymc' has no attribute 'Matplot'" problem

842 views
Skip to first unread message

Dan Dillon

unread,
Apr 9, 2020, 9:59:01 PM4/9/20
to hddm-users
I just created a new python 3.6 environment and am running HDDM 0.7.5 in it, and I could not get the plot_posteriors function to work. When I ran "model.plot_posteriors()" I would get the error listed in the subject line (i.e., module 'pymc' has no attribute 'Matplot'). I found a fix that I figured I'd share in case it's of use to anyone else. I managed to traceback the problem to line 20 in the Matplot.py file in pymc (I'm running pymc 2.3.7). That line looks like this . . . 

from numpy import arange, ravel, rank, swapaxes, concatenate, asarray, ndim


. . . and I don't think "rank" exists in the version of numpy (1.18) that I'm running. Luckily, it doesn't look like rank is actually used anywhere else in that file, so I (a) made a copy of Matplot.py named Matplot_orig.py, in case I come to regret this later, and then (b) deleted "rank" from that one line in Matplot.py, in pymc. Happily, "model.plot_posteriors()" now works fine. 


Dan 

Thomas Wiecki

unread,
Apr 10, 2020, 4:31:04 AM4/10/20
to hddm-...@googlegroups.com
Thanks, Dan! I made the fix in pymc: https://github.com/pymc-devs/pymc/commit/1234330ba9016e955eea6c3a7489f8891b206204 which will be included in the next release.

--
You received this message because you are subscribed to the Google Groups "hddm-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hddm-users/a0221720-5dc0-401d-9e09-5b7c5916a430%40googlegroups.com.

DougieB

unread,
Jan 6, 2021, 6:42:47 AM1/6/21
to hddm-users
Hi Dan,

Thanks for posting your solution. I have just installed hddm 0.8.0 in a new python 3.6 environment with pymc 2.3.7 on a Mac. 
When I try to run the demo at the link below, running m.plot_posteriors(['a', 't', 'v', 'a_std']) returns the message:

File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/kabuki/hierarchical.py", line 859, in plot_posteriors
    pm.Matplot.plot(node['node'], last=save, **kwargs)

AttributeError: module 'pymc' has no attribute 'Matplot'

I have tried to reinstall pymc in my py36 environment using conda install -c anaconda pymc, but this loads 2.3.7. not 2.3.8. I have also tried to edit the Matplot.py file. I don't know how to do this in Python (or how to find the Matplot.py called by m.plot_posteriors) but i have commented line 20 with # and inserted a duplicate at line 21 with rank removed, which I saved using X-code at the path below:

MacOS/opt/anaconda3/envs/py36/lib/python3.6/site-packages/pymc/Matplot.py

 This hasn't resolved the error for me, so could you let me know how you accessed, edited and saved the correct Matplot.py when you solved this issue please?

Many thanks,

Doug. 

DougieB

unread,
Jan 6, 2021, 4:24:04 PM1/6/21
to hddm-users
Just to follow-up on my question above, removing "rank" from line 20 in Matplot.py using X-code has now resolved this issue and I can run the hddm demo code. Note, the pymc update (2.3.8) is available on conda for platforms other than Mac. Thanks again Dan for posting your solution.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages