title: operating on array with condition
body: <p>Consider the following code,</p>
  <pre><code>import numpy as np
  
  xx = np.asarray([1,0,1])
  
  def ff(x):
      return np.sin(x)/x
  
  # this throws an error because of division by zero
  # C:\Users\User\AppData\Local\Temp/ipykernel_2272/525615690.py:4: 
  # RuntimeWarning: invalid value encountered in true_divide
  # return np.sin(x)/x
  
  yy = ff(xx)
  
  # to avoid the error, I did the following
  def ff_smart(x):
      if (x==0):
          # because sin(x)/x = 1 as x-&gt;0
          return 1
      else:
          return np.sin(x)/x
  
  # but then I cannot do
  # yy_smart = ff_smart(xx)
  # because of ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  
  # I therefore have to do:
  
  *yy_smart, = map(ff_smart,xx)
  yy_smart = np.asarray(yy_smart)
  
  </code></pre>
  <p>Is there a way (some numpy magic) to write <code>ff_smart</code> such that I can call it without using <code>map</code> and <code>ff_smart</code> remains operable on scalars (non numpy arrays). I'd like to avoid type-checking in <code>ff_smart</code>.</p>