code: def degrees_of_freedom(self):
          
          if len(self._set_xdata)==0 or len(self._set_ydata)==0: return None
          
          # Temporary hack: get the studentized residuals, which uses the massaged data
          # This should later be changed to get_massaged_data()
          r = self.studentized_residuals()
          
          # Happens if data / functions not defined
          if r == None: return
          
          # calculate the number of points
          N = 0.0
          for i in range(len(r)): N += len(r[i])
          
          return N-len(self._pnames)
docs: Returns the number of degrees of freedom.