Re: IndexError: invalid index to scalar variable. in /matplotlib/ticker.py

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: IndexError: invalid index to scalar variable. in /matplotlib/ticker.py

Mike Lee
Dear Sir or Madam,

I recently posted a bug report on the GitHub discussion page.

I am recently working on updating auto07p to work with matplotlib 2.0.
auto07p is software written for ordinary differential equations.
I encountered the 'IndexError: invalid index to scalar variable.' in '/matplotlib/ticker.py'

It appeared that the
istep = np.nonzero(steps >= raw_step)[0][0]
was trying to access a 1D array without checking its array dimension.

I replaced the line in ticker.py:
istep = np.nonzero(steps >= raw_step)[0][0]

With the following:
arr_dim = np.nonzero(steps >= raw_step).ndim
if arr_dim == 1:

istep = np.nonzero(steps >= raw_step)[0]

elif arr_dim == 2:

istep = np.nonzero(steps >= raw_step)[0][0]

It worked after the above changes. However, I am not absolutely sure correctness of this fix.


May I suggest the developers look further into this issue and resolve this in the future release?




Kind regards,


Mike Lee


_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel