code: def _get_data(data_source, context):
      
      try:
          # Get data from the data source
          data = data_source.source(context)
  
          # Complain about None values
          if data is None:
              raise ValueError("'None' returned from "
                  "data source '{n}'".format(n=context.name))
          # We want numpy arrays
          elif not isinstance(data, np.ndarray):
              raise TypeError("Data source '{n}' did not "
                  "return a numpy array, returned a '{t}'".format(
                      t=type(data)))
          # And they should be the right shape and type
          elif data.shape != context.shape or data.dtype != context.dtype:
              raise ValueError("Expected data of shape '{esh}' and "
                  "dtype '{edt}' for data source '{n}', but "
                  "shape '{rsh}' and '{rdt}' was found instead".format(
                      n=context.name, esh=context.shape, edt=context.dtype,
                      rsh=data.shape, rdt=data.dtype))
  
          return data
  
      except Exception as e:
          ex = ValueError("An exception occurred while "
              "obtaining data from data source '{ds}'\n\n"
              "{e}\n\n"
              "{help}".format(ds=context.name,
                  e=str(e), help=context.help()))
  
          raise ex, None, sys.exc_info()[2]
docs: Get data from the data source, checking the return values