title: Cannot cast array data from dtype('O') to dtype('float64')
body: <p>I am using scipy's curve_fit to fit a function to some data, and receive the following error;</p>
  
  <pre><code>Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'
  </code></pre>
  
  <p>which points me to this line in my code;</p>
  
  <pre><code>popt_r, pcov = curve_fit(
                      self.rightFunc, np.array(wavelength)[beg:end][edgeIndex+30:], 
                      np.dstack(transmitted[:,:,c][edgeIndex+30:])[0][0],
                      p0=[self.m_right, self.a_right])
  </code></pre>
  
  <p>rightFunc is defined as follows;</p>
  
  <pre><code>def rightFunc(self, x, m, const):
  
      return np.exp(-(m*x + const))
  </code></pre>
  
  <p>As I understand it, the 'O' type refers to a python object, but I can't see what is causing this error.</p>
  
  <p>Complete Error:</p>
  
  <p><a href="https://i.stack.imgur.com/2HwF3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2HwF3.png" alt="Image detailing the error received"></a></p>
  
  <p>Any ideas for what I should investigate to get to the bottom of this?</p>