def dataset_range(dataset, start, stop):
 if (dataset.X is None):
  return DenseDesignMatrix(X=None, y=None, view_converter=dataset.view_converter)
 X = dataset.X[start:stop, :].copy()
 if (dataset.y is None):
  y = None
 else:
  if (dataset.y.ndim == 2):
   y = dataset.y[start:stop, :].copy()
  else:
   y = dataset.y[start:stop].copy()
  assert (X.shape[0] == y.shape[0])
 assert (X.shape[0] == (stop - start))
 topo = dataset.get_topological_view(X)
 rval = DenseDesignMatrix(topo_view=topo, y=y)
 rval.adjust_for_viewer = dataset.adjust_for_viewer
 return rval

def dataset_range ( dataset , start , stop ) : if ( dataset . X is None ) : return DenseDesignMatrix ( X = None , y = None , view_converter = dataset . view_converter ) X = dataset . X [ start : stop , : ] . copy ( ) if ( dataset . y is None ) : y = None else : if ( dataset . y . ndim == 2 ) : y = dataset . y [ start : stop , : ] . copy ( ) else : y = dataset . y [ start : stop ] . copy ( ) assert ( X . shape [ 0 ] == y . shape [ 0 ] ) assert ( X . shape [ 0 ] == ( stop - start ) ) topo = dataset . get_topological_view ( X ) rval = DenseDesignMatrix ( topo_view = topo , y = y ) rval . adjust_for_viewer = dataset . adjust_for_viewer return rval
returns a new dataset formed by extracting a range of examples from an existing dataset .