title: How do I insert variable step into Numpy mgrid?
body: <p>I am trying to use numpy.mgrid to create two grid arrays, but I want a way to insert a variable as the number of steps.</p>
  
  <p>Without a variable number of steps, numpy.mgrid works as expected with this code:</p>
  
  <pre><code>x, y = np.mgrid[0:1:3j, 0:2:5j]
  </code></pre>
  
  <p>But, what I want is something like this, because I am not able to explicitly state my step number in the line of code to generate the grid arrays (the values may change due to other processes in my script):</p>
  
  <pre><code>num_x_steps = 3
  num_y_steps = 5
  x, y = np.mgrid[0:1:(num_x_steps)j, 0:2:(num_y_steps)j] #Try convert to complex
  </code></pre>
  
  <p>Is there a way to do that, that returns a result equivalent to the first method?</p>
  
  <p>I tried running my 3-line code with and without parentheses and tried a couple other modifications, but nothing seemed to work.</p>
  
  <p>NOTE: I tried reading <a href="https://stackoverflow.com/questions/28685802/using-numpy-mgrid-with-a-variable-number-of-indices">this</a> topic, but I am not sure if what that topic deals with is applicable to this problem; I don't quite understand what is being asked or how it was answered.  (Also, I tried running the line of code from the answer, and it returned a MemoryError.)  If said topic does answer my problem, could someone please explain it better, and how it applies to my problem?</p>