old_contents: # -*- coding: utf-8 -*-
  
  """This module contains functions for calculating various statistics."""
  from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  
  import numpy as np
  
  
  def residuals(clf, X, y, r_type='standardized'):
      """Calculate residuals or standardized residuals.
  
      Parameters
      ----------
      clf : sklearn.linear_model
          A scikit-learn linear model classifier with a `predict()` method.
      X : numpy.ndarray
          Training data used to fit the classifier.
      y : numpy.ndarray
          Target training values, of shape = [n_samples].
      r_type : str
          Type of residuals to return: ['raw', 'standardized', 'studentized'].
          Defaults to 'standardized'.
  
          * 'raw' will return the raw residuals.
          * 'standardized' will return the standardized residuals, also known as
            internally studentized residuals.
          * 'studentized' will return the externally studentized residuals.
  
      Returns
      -------
      numpy.ndarray
          An array of residuals.
      """
      assert r_type in ('raw', 'standardized', 'studentized'), (
          "Invalid option for 'r_type': {0}".format(r_type)
      )
      y_true = y.view(dtype='float')
      # Use classifier to make predictions
      y_pred = clf.predict(X)
      # Make sure dimensions agree (Numpy still allows subtraction if they don't)
      assert y_true.shape == y_pred.shape, (
          "Dimensions of y_true {0} do not match y_pred {1}".format(y_true.shape,
                                                                    y_pred.shape)
      )
      # Get raw residuals, or standardized or standardized residuals
      resids = y_pred - y_true
      if r_type == 'standardized':
          resids = resids / np.std(resids)
          # TODO (nikhil): make sure this corresponds to standardized residuals
      # TODO (nikhil): calculate externally studentized residuals
      return resids
  
  
  
new_contents: # -*- coding: utf-8 -*-
  
  """This module contains functions for calculating various statistics."""
  from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  
  import numpy as np
  
  
  def residuals(clf, X, y, r_type='standardized'):
      """Calculate residuals or standardized residuals.
  
      Parameters
      ----------
      clf : sklearn.linear_model
          A scikit-learn linear model classifier with a `predict()` method.
      X : numpy.ndarray
          Training data used to fit the classifier.
      y : numpy.ndarray
          Target training values, of shape = [n_samples].
      r_type : str
          Type of residuals to return: ['raw', 'standardized', 'studentized'].
          Defaults to 'standardized'.
  
          * 'raw' will return the raw residuals.
          * 'standardized' will return the standardized residuals, also known as
            internally studentized residuals.
          * 'studentized' will return the externally studentized residuals.
  
      Returns
      -------
      numpy.ndarray
          An array of residuals.
      """
      # Make sure value of parameter 'r_type' is one we recognize
      assert r_type in ('raw', 'standardized', 'studentized'), (
          "Invalid option for 'r_type': {0}".format(r_type)
      )
      y_true = y.view(dtype='float')
      # Use classifier to make predictions
      y_pred = clf.predict(X)
      # Make sure dimensions agree (Numpy still allows subtraction if they don't)
      assert y_true.shape == y_pred.shape, (
          "Dimensions of y_true {0} do not match y_pred {1}".format(y_true.shape,
                                                                    y_pred.shape)
      )
      # Get raw residuals, or standardized or standardized residuals
      resids = y_pred - y_true
      if r_type == 'standardized':
          resids = resids / np.std(resids)
          # TODO (nikhil): make sure this corresponds to standardized residuals
      # TODO (nikhil): calculate externally studentized residuals
      return resids
  
  
  
subject: Add minor comment to residuals() function