Types for built in hoc classes (eg. Vector, File, etc.) have been augmented with a HocClass metaclass in order to recover the HOC internal indexing for object indexing of classes that had been broken by the change to the development version mentioned by ramcdougal above . The original (up through version 8) behavior was
Code: Select all
$ nrniv -python
NEURON -- VERSION 8.2.5....
...
>>> from neuron import h
>>> v = h.Vector(range(3))
>>> v
Vector[0]
>>> type(v)
<class 'hoc.HocObject'>
>>> h.Vector[0]
Vector[0]
>>> h.Vector[0][2]
2.0
>>>
The broken development version 9 version behavior was
Code: Select all
$ nrniv -python
NEURON -- VERSION 9.0a-335-g1d812c87a master (1d812c87a) 2024-09-04
...
>>> from neuron import h
>>> v = h.Vector(range(3))
>>> v
Vector[0]
>>> type(v)
<class 'hoc.Vector'>
>>> type(type(v))
<class 'type'>
>>> h.Vector[0]
Traceback (most recent call last):
File "stdin", line 1, in <module>
TypeError: type 'hoc.Vector' is not subscriptable
>>>
The latest master fixes this issue and now the behavior is
Code: Select all
$ nrniv -python
NEURON -- VERSION 9.0a-341-ge67effdd7 master (e67effdd7) 2024-09-16
...
>>> from neuron import h
>>> v = h.Vector(range(3))
>>> v
Vector[0]
>>> type(v)
<class 'hoc.Vector'>
>>> type(type(v))
<class 'hoc.HocClass'>
>>> type(type(type(v)))
<class 'type'>
>>> h.Vector[0]
Vector[0]
>>> h.Vector[0][2]
2.0
>>>
There is definitely a possibility that we will extend the HocClass metaclass behavior to user defined hoc templates. Presently those exhibit the old version 8 behavior.