title: How to get current value of ndarray in function?
body: <p>There is the function which operates with numpy.ndarray:</p>
  
  <pre><code>def func(x):
      print x # here I need a current value of ndarray
      return 5*x
  </code></pre>
  
  <p>For some calculation I need a current value of passed ndarray, something like <code>np.nditer()</code> while iterating.</p>
  
  <p>Output:</p>
  
  <pre><code>x = array([1, 2, 3]
  In [52]: func(x)
  [1 2 3]
  Out[52]: array([5, 10, 15])
  </code></pre>
  
  <p>Some <strong><em>upd</em></strong>:</p>
  
  <p>I need to plot next sequence:</p>
  
  <p><img src="https://i.stack.imgur.com/DLfjH.gif" alt="enter image description here"></p>
  
  <p>I've wrote function which perfectly works with single values:</p>
  
  <pre><code>In [54]: def my_formula(x):
      ...:     return sum([1/(math.sqrt(i)) for i in range(1, x+1)]
  </code></pre>
  
  <p>but I need to transfom it for plotting:</p>
  
  <pre><code>def graph(formula, x_range):  
      x = np.array(x_range)  
      y = formula(x) # numpy ndarray!
      plt.plot(x, y)  
      plt.show()
  </code></pre>
  
  <p>so here</p>
  
  <pre><code>return sum([1/(math.sqrt(i)) for i in range(1, x+1)]
  </code></pre>
  
  <p>I need a current element of <code>ndarray</code>, not a full range for <code>range(1, x+1)</code></p>