<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def degrees_of_freedom(self):
 """ Returns the number of degrees of freedom. """

        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)