pydstool icon indicating copy to clipboard operation
pydstool copied to clipboard

Indexing error while running zero-crossing events in the Van der Pol oscillator

Open Shibabrat opened this issue 7 years ago • 3 comments

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 "", line 12, in fp_coord = pp.find_fixedpoints(vdp, n=4, eps=1e-8)[0]

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 x0 = array([x0_coords[i][d_posns[i]] for i in range(D)])

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

Shibabrat avatar Sep 26 '17 15:09 Shibabrat

I'm getting the same error.

tristan3214 avatar Oct 23 '17 04:10 tristan3214

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.

tristan3214 avatar Oct 23 '17 16:10 tristan3214

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.

tensionhead avatar Dec 10 '17 11:12 tensionhead