example for numpy.mgrid doesn't work
Hello! I type in sage notebook 5.8 on my local computer:
import numpy as np
np.mgrid?
....
example:
>>> np.mgrid[-1:1:5j]
array([-1. , -0.5, 0. , 0.5, 1. ])
But when I type in my notebook:
np.mgrid[-1:1:5j]
and press shift-enter, I get mistake: TypeError: Unable to convert -0.200000000000000*I to float; use abs() or real_part() as desired
It seems to me it's the bug...
That's the preparser. Well, in Python typically `1j**2` becomes `(-1+0j)`; `j` is a complex number ala electrical engineering. What surprises me is that numpy would use j for some other purpose.
Indeed, in the documentation for `mgrid`: "However, if the step length is a **complex number** (e.g. 5j)," so basically this is a numpy hack, in my opinion.