[Matplotlib-devel] IndexError: invalid index to scalar variable. in /matplotlib/ticker.py

Mike Lee st970703 at gmail.com
Sun Jul 23 20:42:51 EDT 2017


Dear Sir or Madam,

I recently posted a bug report on the GitHub discussion page.
https://github.com/matplotlib/matplotlib/issues/8881

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20170724/b3adcaf4/attachment-0001.html>


More information about the Matplotlib-devel mailing list