pydstool
pydstool copied to clipboard
Indexing error while running zero-crossing events in the Van der Pol oscillator
I am replicating the results in the tutorial here http://www.ni.gsu.edu/~rclewley/PyDSTool/Tutorial/Tutorial_VdP.html
But computing the fixed points in the 3rd code segment throws the following error:
Traceback (most recent call last):
File "
File "/Users/shibabrat/anaconda/lib/python3.6/site-packages/PyDSTool-0.90.2-py3.6.egg/PyDSTool/Toolbox/phaseplane.py", line 1350, in find_fixedpoints x0 = array([x0_coords[i][d_posns[i]] for i in range(D)])
File "/Users/shibabrat/anaconda/lib/python3.6/site-packages/PyDSTool-0.90.2-py3.6.egg/PyDSTool/Toolbox/phaseplane.py", line 1350, in
IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
Can someone kindly direct me on how to resolve this issue? I am running this test on the clone of the github repo.
Thanks, Naik
I'm getting the same error.
I played around with the source code and it appears the d_posns
is the issue. It is a float array that is being used in line 1350 (in phaseplane.py) to index x0_coords
, which is causing the index error. I don't know a whole lot of what the code is doing, but when I place int(d_posns[i])
in as the index it solves my problem. I can't guarantee this is a fix but I know it worked because I get the same answer for fixed points in pplane for Matlab.
I am running in exactly the same issue, numpy >= 1.?? requires strictly integer arrays as indexers. It seems as if PyDSTool for python3 does not respect this atm. As 'd_posns' is an instance of the 'base_n_counter' class in phaseplane.py, I changed:
self.counter = np.zeros((d,))
to
self.counter = np.zeros((d,), dtype = int)
in init of the counter class to solve that issue.