Initialize Dataset from given Daru::Vector
977035
def init_daru_vector(data, options)
      options[:using] ||= get_daru_columns(data, 2)
      options[:title] ||= data.name
      init_default(data, options)
    end
189092
function initialize(o, datasets) {
      var www;

      datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1);

      o = o || {};
      www = WWW(o.classNames);

      return this.each(attach);

      function attach() {
        var $input, $wrapper, $hint, $menu, defaultHint, defaultMenu,
            eventBus, input, menu, typeahead, MenuConstructor;

        // highlight is a top-level config that needs to get inherited
        // from all of the datasets
        _.each(datasets, function(d) { d.highlight = !!o.highlight; });

        $input = $(this);
        $wrapper = $(www.html.wrapper);
        $hint = $elOrNull(o.hint);
        $menu = $elOrNull(o.menu);

        defaultHint = o.hint !== false && !$hint;
        defaultMenu = o.menu !== false && !$menu;

        defaultHint && ($hint = buildHintFromInput($input, www));
        defaultMenu && ($menu = $(www.html.menu).css(www.css.menu));

        // hint should be empty on init
        $hint && $hint.val('');
        $input = prepInput($input, www);

        // only apply inline styles and make dom changes if necessary
        if (defaultHint || defaultMenu) {
          $wrapper.css(www.css.wrapper);
          $input.css(defaultHint ? www.css.input : www.css.inputWithNoHint);

          $input
          .wrap($wrapper)
          .parent()
          .prepend(defaultHint ? $hint : null)
          .append(defaultMenu ? $menu : null);
        }

        MenuConstructor = defaultMenu ? DefaultMenu : Menu;

        eventBus = new EventBus({ el: $input });
        input = new Input({ hint: $hint, input: $input, }, www);
        menu = new MenuConstructor({
          node: $menu,
          datasets: datasets
        }, www);

        typeahead = new Typeahead({
          input: input,
          menu: menu,
          eventBus: eventBus,
          minLength: o.minLength
        }, www);

        $input.data(keys.www, www);
        $input.data(keys.typeahead, typeahead);
      }
    }
1147046
def _create_dataset(self, *data):
        """"""
        # Make sure data is a tuple of dense tensors
        data = [self._to_torch(x, dtype=torch.FloatTensor) for x in data]
        return TensorDataset(*data)
858598
def create(cls, train_ds:Dataset, valid_ds:Dataset, test_ds:Optional[Dataset]=None, path:PathOrStr='.', bs:int=64,
               val_bs:int=None, num_workers:int=defaults.cpus, dl_tfms:Optional[Collection[Callable]]=None,
               device:torch.device=None, collate_fn:Callable=data_collate, no_check:bool=False, **dl_kwargs)->'DataBunch':
        ""
        datasets = cls._init_ds(train_ds, valid_ds, test_ds)
        val_bs = ifnone(val_bs, bs)
        dls = [DataLoader(d, b, shuffle=s, drop_last=s, num_workers=num_workers, **dl_kwargs) for d,b,s in
               zip(datasets, (bs,val_bs,val_bs,val_bs), (True,False,False,False)) if d is not None]
        return cls(*dls, path=path, device=device, dl_tfms=dl_tfms, collate_fn=collate_fn, no_check=no_check)
280553
def dump_all_arrays(dataset_dir, data_dir, dataset, root=None, compress=True):
    """"""
    if root is None:
        root = {}
    root['pointData'] = {
        'vtkClass': 'vtkDataSetAttributes',
        "activeGlobalIds": -1,
        "activeNormals": -1,
        "activePedigreeIds": -1,
        "activeScalars": -1,
        "activeTCoords": -1,
        "activeTensors": -1,
        "activeVectors": -1,
        "arrays": []
    }
    root['cellData'] = {
        'vtkClass': 'vtkDataSetAttributes',
        "activeGlobalIds": -1,
        "activeNormals": -1,
        "activePedigreeIds": -1,
        "activeScalars": -1,
        "activeTCoords": -1,
        "activeTensors": -1,
        "activeVectors": -1,
        "arrays": []
    }
    root['fieldData'] = {
        'vtkClass': 'vtkDataSetAttributes',
        "activeGlobalIds": -1,
        "activeNormals": -1,
        "activePedigreeIds": -1,
        "activeScalars": -1,
        "activeTCoords": -1,
        "activeTensors": -1,
        "activeVectors": -1,
        "arrays": []
    }

    # Point data
    pd = dataset.GetPointData()
    pd_size = pd.GetNumberOfArrays()
    for i in range(pd_size):
        array = pd.GetArray(i)
        if array:
            dumped_array = dump_data_array(
                dataset_dir, data_dir, array, {}, compress)
            root['pointData']['activeScalars'] = 0
            root['pointData']['arrays'].append({'data': dumped_array})

    # Cell data
    cd = dataset.GetCellData()
    cd_size = pd.GetNumberOfArrays()
    for i in range(cd_size):
        array = cd.GetArray(i)
        if array:
            dumped_array = dump_data_array(
                dataset_dir, data_dir, array, {}, compress)
            root['cellData']['activeScalars'] = 0
            root['cellData']['arrays'].append({'data': dumped_array})

    return root
112724
def filter_vector vec, &block
      Daru::Vector.new(each_row.select(&block).map { |row| row[vec] })
    end
265959
@Override
   public Dataset convert(Object s) {
      if (s instanceof Dataset) {
         return (Dataset) s;
      } else {
         throw new VectorPrintRuntimeException(String.format(
             "override this method to convert %s (value: %s) to a Dataset",
             (s != null) ? s.getClass().getName() : null, String.valueOf(s)
         ));
      }
   }
701262
def parse(data)
      # Assumes that each file has exactly the same structure
      result_df = nil
      Array(data).each_with_index do |filename, idx|
        filename = filename.to_s

        logger.info "Converting #{filename} to a dataframe"
        processed_filename = preprocess(filename)
        csv_df = Daru::DataFrame.from_csv processed_filename, @csv_options

        # Daru 0.1.4 doesn't add vectors if it's a headers-only file
        if csv_df.vectors.size == 0
          headers_df = Daru::DataFrame.from_csv processed_filename, @csv_options.merge(return_headers: true)
          csv_df = Daru::DataFrame.new([], order: headers_df.vectors.to_a)
        end

        csv_df[@filename_field] = Daru::Vector.new([filename] * csv_df.size, index: csv_df.index) if @filename_field
        if idx == 0
          result_df = csv_df
        else
          result_df = result_df.concat csv_df
        end
      end

      Remi::DataFrame.create(:daru, result_df)
    end
694352
def _load_dataset(name, data_home=None, return_dataset=False):
    
    info = DATASETS[name]
    data = Dataset(name, data_home=data_home, **info)
    if return_dataset:
        return data
    return data.to_data()
167536
protected void initializeUniformWeight() {
    if ((problem.getNumberOfObjectives() == 2) && (populationSize <= 300)) {
      for (int n = 0; n < populationSize; n++) {
        double a = 1.0 * n / (populationSize - 1);
        lambda[n][0] = a;
        lambda[n][1] = 1 - a;
      }
    } else {
      String dataFileName;
      dataFileName = "W" + problem.getNumberOfObjectives() + "D_" +
          populationSize + ".dat";

      try {

        //       String path =
        // Paths.get(VectorFileUtils.class.getClassLoader().getResource(filePath).toURI()).toString
        // ();
        InputStream in =
            getClass()
                .getClassLoader()
                .getResourceAsStream(dataDirectory + "/" + dataFileName);
        InputStreamReader isr = new InputStreamReader(in);
        BufferedReader br = new BufferedReader(isr);

        int i = 0;
        int j = 0;
        String aux = br.readLine();
        while (aux != null) {
          StringTokenizer st = new StringTokenizer(aux);
          j = 0;
          while (st.hasMoreTokens()) {
            double value = new Double(st.nextToken());
            lambda[i][j] = value;
            j++;
          }
          aux = br.readLine();
          i++;
        }
        br.close();
      } catch (Exception e) {
        throw new JMetalException("initializeUniformWeight: failed when reading for file: "
            + dataDirectory + "/" + dataFileName, e) ;
      }
    }
  }
979047
def create_dataset(
            self, group, chunk_size, compression=None, compression_opts=None):
        """"""
        group.attrs['format'] = self.dformat
        super(Features, self)._create_dataset(
            group, chunk_size, compression, compression_opts)

        # TODO attribute declared outside __init__ is not safe. Used
        # because Labels.create_dataset need it.
        if chunk_size != 'auto':
            self.nb_per_chunk = nb_per_chunk(
                self.dtype.itemsize, self.dim, chunk_size)
        else:
            self.nb_per_chunk = 'auto'
653347
def populateFromRow(self, dataset):
        
        self._description = dataset.description
        self.setAttributesJson(dataset.attributes)
594673
def dataset_to_stream(dataset, input_name, num_chunks=0, append_targets=False):
  """"""
  for example in tfds.as_numpy(dataset):
    inp, out = example[0][input_name], example[1]
    if len(out.shape) > 1 and out.shape[-1] == 1:
      out = np.squeeze(out, axis=-1)
    if num_chunks > 0:
      inp = np.split(inp, num_chunks, axis=1)
      out = np.split(out, num_chunks, axis=1)
    if append_targets:
      inp = (inp, out)
    yield inp, out
81106
def _initialise_data(self, memmap_dir=None):
        """"""

        if self.number_values == 0:
            pass
        elif self.data_type.nptype is None:
            self._data = []
        else:
            if memmap_dir:
                memmap_file = tempfile.NamedTemporaryFile(
                    mode='w+b', prefix="nptdms_", dir=memmap_dir)
                self._data = np.memmap(
                    memmap_file.file,
                    mode='w+',
                    shape=(self.number_values,),
                    dtype=self.data_type.nptype)
            else:
                self._data = np.zeros(
                    self.number_values, dtype=self.data_type.nptype)
            self._data_insert_position = 0
        if self._data is not None:
            log.debug("Allocated %d sample slots for %s", len(self._data),
                      self.path)
        else:
            log.debug("Allocated no space for %s", self.path)
1229385
def init(self):
        """"""

        evclass_shape = [16, 40, 10]
        evtype_shape = [16, 16, 40, 10]
        evclass_psf_shape = [16, 40, 10, 100]
        evtype_psf_shape = [16, 16, 40, 10, 100]

        self._hists_eff = dict()
        self._hists = dict(evclass_on=np.zeros(evclass_shape),
                           evclass_off=np.zeros(evclass_shape),
                           evclass_alpha=np.zeros([16, 40, 1]),
                           evtype_on=np.zeros(evtype_shape),
                           evtype_off=np.zeros(evtype_shape),
                           evtype_alpha=np.zeros([16, 1, 40, 1]),
                           evclass_psf_on=np.zeros(evclass_psf_shape),
                           evclass_psf_off=np.zeros(evclass_psf_shape),
                           evtype_psf_on=np.zeros(evtype_psf_shape),
                           evtype_psf_off=np.zeros(evtype_psf_shape),
                           )
1098276
def init(self):
        """"""
        from itertools import chain

        def maybe_int(v):
            try:
                return int(v)
            except ValueError:
                return None

        if not self.initialized:

            self.data_start_line = 1
            self.data_end_line = None
            self.header_lines = [0]

            if self.source.start_line:
                self.data_start_line = self.source.start_line
            if self.source.end_line:
                self.data_end_line = self.source.end_line
            if self.source.header_lines:
                self.header_lines = list(map(maybe_int, self.source.header_lines))
            if self.source.comment_lines:
                self.header_comment_lines = list(map(maybe_int, self.source.comment_lines))

            max_header_line = max(chain(self.header_comment_lines, self.header_lines))

            if self.data_start_line <= max_header_line:
                self.data_start_line = max_header_line + 1

            if not self.header_comment_lines:
                min_header_line = min(chain(self.header_lines))
                if min_header_line:
                    self.header_comment_lines = list(range(0, min_header_line))

            self.headers = []
            self.header_comments = []
            self.footers = []

            self.initialized = True
            self.i = 0
916077
def _inner_dataset_template(cls, dataset):
        
        from . import Dataset
        vdims = dataset.vdims if getattr(dataset, 'level', None) is None else []
        return Dataset(dataset.data[0], datatype=cls.subtypes,
                       kdims=dataset.kdims, vdims=vdims)