TypeError: 'NoneType' object is not subscriptable

460 views
Skip to first unread message

Michael Spezio

unread,
Nov 6, 2018, 11:19:17 AM11/6/18
to hddm-users
Dear Dr. Wiecki,

Does the new version of HDDM and kabuki work with pymc3? Has kabuki itself been updated? I am using a Mac running High Sierra with python36.

I am able to sample successfully using the example HDDM data.

I am encountering an error running HDDM with pymc 2.3.6 that several other users have reported:

TypeError: 'NoneType' object is not subscriptable

This seems to be related to the hierarchical.py function in kabuki and possibly related to pymc.

So my questions are:

 
  1. Has there been a good solution found?
  2. Should I be using pymc3 or staying with the earlier version?
  3. Has kabuki itself been updated to use pymc3 or does it only work with the earlier version?

 
Thank you very much for your help with this.

Best wishes,

Michael

Samuel Mathias

unread,
Nov 6, 2018, 11:28:38 AM11/6/18
to hddm-...@googlegroups.com
No it doesn’t. Pymc3 has a completely different code base to pymc 2. There’s likely not much point porting, either, since the DDM likelihood functions probably can’t be differentiated to make use of the superior NUTS sampler. In other words, Pymc 2 is a requirement for HDDM; pymc 3 is irrelevant.

--
Samuel R. Mathias, Ph.D.
Associate Research Scientist (ARS)
Neurocognition, Neurocomputation and Neurogenetics (n3) Division
Yale University School of Medicine
40 Temple Street, Room 694
New Haven CT 06510

From: hddm-...@googlegroups.com <hddm-...@googlegroups.com> on behalf of Michael Spezio <mlsp...@gmail.com>
Sent: Tuesday, November 6, 2018 11:19:16 AM
To: hddm-users
Subject: [hddm-users] TypeError: 'NoneType' object is not subscriptable
 
--
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.
For more options, visit https://groups.google.com/d/optout.

Michael Spezio

unread,
Nov 6, 2018, 4:36:00 PM11/6/18
to hddm-users
Thank you Sam.

Then my first question seems relevant: Has anyone found a good solution to the error that seems to keep popping up for some users of hddm?

The error happens after sampling in gen_stats in hierarchical.py:

  File "/Users/mspezio/anaconda3/lib/python3.6/site-packages/kabuki/hierarchical.py", line 732, in gen_stats
    self.append_stats_to_nodes_db()

 File "/Users/mspezio/anaconda3/lib/python3.6/site-packages/kabuki/hierarchical.py", line 784, in append_stats_to_nodes_db
    self.nodes_db.loc[name, 'mean']   = i_stats['mean']

TypeError: 'NoneType' object is not subscriptable

This is with

hddm 0.6.1
numpy 1.15.3
pymc 2.3.6
kabuki 0.6.2
pandas 0.23.4

in spyder 3.3.1 running python36

Thanks, Michael

Dan Dillon

unread,
Nov 7, 2018, 11:51:44 AM11/7/18
to hddm-...@googlegroups.com
Hi Michael. Not sure but I think you might be using a version of numpy that's too new--I think you may need to bump it down to 1.11.x. See here for a relevant thread: https://tinyurl.com/y8hafefc

Dan

--

Michael Spezio

unread,
Nov 8, 2018, 2:03:02 AM11/8/18
to hddm-users
Thanks Dan.

I think that my issue was py36. I created a dedicated py27 environment and hddm seems to be running smoothly in that after I followed the conda install under py27.

I have other questions but I'll post those to a separate thread.

Thanks very much.

Michael

rahul kumar

unread,
Nov 6, 2019, 11:37:29 PM11/6/19
to hddm-users
In general, the error means that you attempted to index an object that doesn't have that functionality. You are trying to subscript an object which you think is a list or dict, but actually is None. NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return a value will return None. 'NoneType' object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn't define the __getitem__ method .

Sophie Paolizzi

unread,
Nov 20, 2019, 8:10:14 PM11/20/19
to hddm-users
Hi all,

I am experiencing this error as well (Nonetype object is unsubscriptable) on Python 3.7 with the pymc install from github. I tried downgrading my numpy to 11.1.3, but then it refused to import hddm saying that my numpy was too deprecated. So with the updated version of numpy, I am still getting this error when I try to run a model: 


TypeError                                 Traceback (most recent call last)
<ipython-input-65-b143e7239d7b> in <module>
     11         ArPos_Scaled2 = hddm.HDDMRegressor(data,baseline_v, group_only_regressors=['false'])
     12         ArPos_Scaled2.find_starting_values()
---> 13         ArPos_Scaled2.sample(nsample, burn = nburn, dbname = 'ArPos_Scaled2.db', db = 'pickle')
     
/usr/local/lib/python3.6/site-packages/kabuki/hierarchical.py in sample(self, *args, **kwargs)
    653         self.sampled = True
    654 
--> 655         self.gen_stats()
    656         return self.mc
    657 

/usr/local/lib/python3.6/site-packages/kabuki/hierarchical.py in gen_stats(self, fname, print_hidden, **kwargs)
    730             print_hidden <bool>  - print statistics of hidden nodes
    731         """
--> 732         self.append_stats_to_nodes_db()
    733 
    734         sliced_db = self.nodes_db.copy()

/usr/local/lib/python3.6/site-packages/kabuki/hierarchical.py in append_stats_to_nodes_db(self, *args, **kwargs)
    782             if self.nodes_db.loc[name, 'hidden']:
    783                 continue
--> 784             self.nodes_db.loc[name, 'mean']   = i_stats['mean']
    785             self.nodes_db.loc[name, 'std']    = i_stats['standard deviation']
    786             self.nodes_db.loc[name, '2.5q']   = i_stats['quantiles'][2.5]

TypeError: 'NoneType' object is not subscriptable


Here are the versions I have of the relevant packages: 

HDDM: 0.7.1
PANDAS:0.25.1
NUMPY: 1.17.0
PYMC: 2.3.6
KABUKI: 0.6.2

any further clarification on this issue would be much appreciate!

Best,
Sophie
To unsubscribe from this group and stop receiving emails from it, send an email to hddm-...@googlegroups.com.

Michael Spezio

unread,
Dec 5, 2019, 11:38:58 AM12/5/19
to hddm-users
I think the challenges with installing HDDM under 3.5 or 3.6 continue to persist even after the update to 0.7.1. I wonder if anyone has a sense of whether this is due to kabuki and compatibility with numpy versions under python3 or if there is a limited set of approaches that one can try and that are known to work most of the time in successfully installing HDDM 0.7.1 under python3?

I have tried with 3.5, 3.6, and 3.7. Under 3.5 and 3.6, I'm able to install using pip (ensuring that cython is installed prior to installing hddm) and I'm able to run the tutorial simple model estimation successfully. However, I also am unable to get past the issue that occurs around 784 in hierarchical.py in kabuki.

If any of the expert developers has a solution or a set of likely solutions, could you please share?

Thanks so much. Best, Michael


On Tuesday, November 6, 2018 at 8:19:17 AM UTC-8, Michael Spezio wrote:
Reply all
Reply to author
Forward
0 new messages