Opens the root Dataset.
975077
def _openResources(self):
        
        logger.info("Opening: {}".format(self._fileName))
        self._ncGroup = Dataset(self._fileName)
915087
def open_dataset(self, recent=None, debug_filename=None, bids=False):
        
        if recent:
            filename = recent

        elif debug_filename is not None:
            filename = debug_filename

        else:
            try:
                dir_name = dirname(self.filename)
            except (AttributeError, TypeError):
                dir_name = self.parent.value('recording_dir')

            file_or_dir = choose_file_or_dir()
            if file_or_dir == 'dir':
                filename = QFileDialog.getExistingDirectory(self,
                                                            'Open directory',
                                                            dir_name)
            elif file_or_dir == 'file':
                filename, _ = QFileDialog.getOpenFileName(self, 'Open file',
                                                          dir_name)

            elif file_or_dir == 'abort':
                return

        if filename == '':
            return

        # clear previous dataset once the user opens another dataset
        if self.dataset is not None:
            self.parent.reset()

        self.parent.statusBar().showMessage('Reading dataset: ' +
                                            basename(filename))
        lg.info('Reading dataset: ' + str(filename))
        self.filename = filename # temp
        self.dataset = Dataset(filename) #temp
#==============================================================================
#         try:
#             self.filename = filename
#             self.dataset = Dataset(filename)
#         except FileNotFoundError:
#             msg = 'File ' + basename(filename) + ' cannot be read'
#             self.parent.statusBar().showMessage(msg)
#             lg.info(msg)
#             error_dialog = QErrorMessage()
#             error_dialog.setWindowTitle('Error opening dataset')
#             error_dialog.showMessage(msg)
#             if debug_filename is None:
#                 error_dialog.exec()
#             return
#
#         except BaseException as err:
#             self.parent.statusBar().showMessage(str(err))
#             lg.info('Error ' + str(err))
#             error_dialog = QErrorMessage()
#             error_dialog.setWindowTitle('Error opening dataset')
#             error_dialog.showMessage(str(err))
#             if debug_filename is None:
#                 error_dialog.exec()
#             return
#==============================================================================

        self.action['export'].setEnabled(True)

        self.parent.statusBar().showMessage('')

        self.parent.update()
514653
def open(self):
        '''
        
        '''
        if self.__arch is not None:
            raise salt.exceptions.SaltException('Archive already opened.')
        self.__arch = tarfile.TarFile.bz2open(self.archive_path, 'w')
82788
function() {
		var me = this;
		helpers$1.each(me.data.datasets, function(dataset, datasetIndex) {
			me.getDatasetMeta(datasetIndex).controller.reset();
		}, me);
	}
595570
def start(self):
        
        # load default input data for the state
        self._root_state.input_data = self._root_state.get_default_input_values_for_state(self._root_state)
        self._root_state.output_data = self._root_state.create_output_dictionary_for_state(self._root_state)
        new_execution_history = self._add_new_execution_history()
        new_execution_history.push_state_machine_start_history_item(self, run_id_generator())
        self._root_state.start(new_execution_history)
465789
def _load_dataset(dsid, ds_info, file_handlers, dim='y'):
        """"""
        slice_list = []
        failure = True
        for fh in file_handlers:
            try:
                projectable = fh.get_dataset(dsid, ds_info)
                if projectable is not None:
                    slice_list.append(projectable)
                    failure = False
            except KeyError:
                logger.warning("Failed to load {} from {}".format(dsid, fh),
                               exc_info=True)

        if failure:
            raise KeyError(
                "Could not load {} from any provided files".format(dsid))

        if dim not in slice_list[0].dims:
            return slice_list[0]
        res = xr.concat(slice_list, dim=dim)

        combined_info = file_handlers[0].combine_info(
            [p.attrs for p in slice_list])

        res.attrs = combined_info
        return res
81853
def main(dataset1, dataset2, target):
    
    d1 = read_raw(dataset1)
    d2 = read_raw(dataset2)
    merged = merge(d1, d2)
    with open(target, 'wb') as f:
        pickle.dump(merged, f, protocol=pickle.HIGHEST_PROTOCOL)
1301411
def create_dataset_file(root_dir, data):
  """"""
  file_path = os.path.join(root_dir, '{dataset_type}', '{dataset_name}.py')
  context = (
      _HEADER + _DATASET_DEFAULT_IMPORTS + _CITATION
      + _DESCRIPTION + _DATASET_DEFAULTS
  )

  with gfile.GFile(file_path.format(**data), 'w') as f:
    f.write(context.format(**data))
858765
def _read_datasets(self, dataset_nodes, **kwargs):
        """"""
        # Sort requested datasets by reader
        reader_datasets = {}

        for node in dataset_nodes:
            ds_id = node.name
            # if we already have this node loaded or the node was assigned
            # by the user (node data is None) then don't try to load from a
            # reader
            if ds_id in self.datasets or not isinstance(node.data, dict):
                continue
            reader_name = node.data.get('reader_name')
            if reader_name is None:
                # This shouldn't be possible
                raise RuntimeError("Dependency tree has a corrupt node.")
            reader_datasets.setdefault(reader_name, set()).add(ds_id)

        # load all datasets for one reader at a time
        loaded_datasets = DatasetDict()
        for reader_name, ds_ids in reader_datasets.items():
            reader_instance = self.readers[reader_name]
            new_datasets = reader_instance.load(ds_ids, **kwargs)
            loaded_datasets.update(new_datasets)
        self.datasets.update(loaded_datasets)
        return loaded_datasets
596876
def _open_for_read(self):
        """"""
        ownerid, datasetid = parse_dataset_key(self._dataset_key)
        response = requests.get(
            '{}/file_download/{}/{}/{}'.format(
                self._query_host, ownerid, datasetid, self._file_name),
            headers={
                'User-Agent': self._user_agent,
                'Authorization': 'Bearer {}'.format(
                    self._config.auth_token)
            }, stream=True)
        try:
            response.raise_for_status()
        except Exception as e:
            raise RestApiError(cause=e)
        self._read_response = response
1281275
private void loadRootFolder() {
        new Thread() {
            @Override
            public void run() {
                try {
                    //Api to fetch root folder
                    final BoxIteratorItems folderItems = mFolderApi.getItemsRequest(BoxConstants.ROOT_FOLDER_ID).send();
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mAdapter.clear();
                            for (BoxItem boxItem: folderItems) {
                                mAdapter.add(boxItem);
                            }
                        }
                    });
                } catch (BoxException e) {
                    e.printStackTrace();
                }

            }
        }.start();
    }
937673
def open_file(path, grib_errors='warn', **kwargs):
    """"""
    if 'mode' in kwargs:
        warnings.warn("the `mode` keyword argument is ignored and deprecated", FutureWarning)
        kwargs.pop('mode')
    stream = messages.FileStream(path, message_class=cfmessage.CfMessage, errors=grib_errors)
    return Dataset(*build_dataset_components(stream, **kwargs))
1154967
def load(self, dataset_keys, previous_datasets=None):
        """"""
        all_datasets = previous_datasets or DatasetDict()
        datasets = DatasetDict()

        # Include coordinates in the list of datasets to load
        dsids = [self.get_dataset_key(ds_key) for ds_key in dataset_keys]
        coordinates = self._get_coordinates_for_dataset_keys(dsids)
        all_dsids = list(set().union(*coordinates.values())) + dsids

        for dsid in all_dsids:
            if dsid in all_datasets:
                continue
            coords = [all_datasets.get(cid, None)
                      for cid in coordinates.get(dsid, [])]
            ds = self._load_dataset_with_area(dsid, coords)
            if ds is not None:
                all_datasets[dsid] = ds
                if dsid in dsids:
                    datasets[dsid] = ds
        self._load_ancillary_variables(all_datasets)

        return datasets
920871
def get_dataset(self, key, info):
        """"""
        logger.debug("Reading %s.", key)
        return self.file_content[key.name]
634161
def open(self):
        

        with open(self.path, 'r') as f:
            corrected = f.read().replace('rdf:resource rdf:resource',
                                         'link:link rdf:resource')
        with open(self.path, 'w') as f:
            f.write(corrected)

        super(ZoteroParser, self).open()
511378
def main():
    
    ROOT_LOGGER.setLevel(logging.DEBUG)

    file_handler = logging.StreamHandler(LOG_PATH.open("wt"))
    formatter = logging.Formatter(LOG_FORMAT)
    file_handler.setFormatter(formatter)
    file_handler.setLevel(logging.DEBUG)
    ROOT_LOGGER.addHandler(file_handler)

    terminal_handler = logging.StreamHandler(stdout)
    terminal_handler.setFormatter(formatter)
    terminal_handler.setLevel(logging.INFO)
    ROOT_LOGGER.addHandler(terminal_handler)

    LOGGER.debug("Parsing command-line arguments")
    parser = ArgumentParser(
        description="""
            Use datasets, and judgements in the NTCIR-11 Math-2, and NTCIR-12 MathIR XHTML5 format
            to compute density, and probability estimates.
        """)
    parser.add_argument(
        "--datasets", nargs='+', required=False,
        type=lambda s: LabelledPath(s.split('=', 1)[0], Path(s.split('=', 1)[1])), help="""
            Paths to the directories containing the datasets. Each path must be prefixed with a
            unique single-letter label followed by an equals sign (e.g. "A=/some/path").
        """)
    parser.add_argument(
        "--judgements", nargs='+', required=False,
        type=lambda s: (LabelledPath.labels[s.split(':', 1)[0]], Path(s.split(':', 1)[1])), help="""
            Paths to the files containing relevance judgements. Each path must be prefixed with a
            single-letter label corresponding to the judged dataset followed by a semicolon (e.g.
            "A:/some/path/judgement.dat").
        """)
    parser.add_argument(
        "--plots", type=Path, nargs='+', help="""
            The path to the files, where the probability estimates will plotted. When no datasets
            are specified, the estimates file will be loaded.
        """)
    parser.add_argument(
        "--positions", type=Path, default=POSITIONS_ALL_PATH, help="""
            The path to the file, where the estimated positions of all paragraph identifiers from
            all datasets will be stored. Defaults to %(default)s.
        """)
    parser.add_argument(
        "--estimates", type=Path, default=ESTIMATES_PATH, help="""
            The path to the file, where the density, and probability estimates will be stored. When
            no datasets are specified, this file will be loaded to provide the estimates for
            plotting. Defaults to %(default)s.
        """)
    parser.add_argument(
        "--num-workers", type=int, default=1, help="""
            The number of processes that will be used for processing the datasets, and for computing
            the density, and probability estimates. Defaults to %(default)d.
        """)
    args = parser.parse_args()

    LOGGER.debug("Performing sanity checks on the command-line arguments")
    if args.datasets:
        for dataset in args.datasets:
            assert dataset.path.exists() and dataset.path.is_dir(), \
                "Dataset %s does not exist" % dataset.path
        assert args.judgements, "No relevance judgements were specified for the datasets"
        for _, judgement_path in args.judgements:
            assert judgement_path.exists() and judgement_path.is_file(), \
                "Relevance judgement %s does not exist" % judgement_path
        assert not args.estimates.exists() or args.estimates.is_file(), \
            "File %s, where estimates are to be stored, is non-regular." % args.estimates
        if args.positions.exists():
            LOGGER.warning("%s exists", args.positions.name)
        if args.estimates.exists():
            LOGGER.warning("%s exists", args.estimates.name)
    if args.plots:
        assert args.datasets or args.estimates, \
            "Neither datasets, not a stored file with estimates was provided as a plot source"
        if not args.datasets:
            assert args.estimates.exists() and args.estimates.is_file(), \
                "The file %s with estimates does not exist" % args.estimates
        for plot in args.plots:
            assert plot.parents[0].exists() and plot.parents[0].is_dir(), \
                "Directory %s, where a plot is to be stored, does not exist" % \
                plot.parents[0]
            if plot.exists():
                LOGGER.warning("%s exists", plot)
    assert args.positions.parents[0].exists() and args.positions.parents[0].is_dir(), \
        "Directory %s, where the positions are to be stored, does not exist" % \
        args.positions.parents[0]
    assert args.estimates.parents[0].exists() and args.estimates.parents[0].is_dir(), \
        "Directory %s, where the estimates are to be stored, does not exist" % \
        args.estimates.parents[0]
    assert args.num_workers > 0, "The number of workers must be non-negative"

    if args.datasets:
        identifiers_judged = {}
        identifiers_relevant = {}
        for dataset_path, judgement_path in args.judgements:
            LOGGER.info(
                "Retrieving judged paragraph identifiers, and scores from %s", judgement_path.name)
            if dataset_path not in identifiers_judged:
                identifiers_judged[dataset_path] = set()
            if dataset_path not in identifiers_relevant:
                identifiers_relevant[dataset_path] = set()
            with judgement_path.open("rt") as f:
                for identifier, score in get_judged_identifiers(f):
                    identifiers_judged[dataset_path].add(identifier)
                    if score > MIN_RELEVANT_SCORE:
                        identifiers_relevant[dataset_path].add(identifier)

        identifiers_all = {}
        positions_all = {}
        positions_relevant = {}
        for dataset in args.datasets:
            LOGGER.info(
                "Retrieving all paragraph identifiers, and positions from %s", dataset.path.name)
            identifiers_all[dataset.path] = []
            positions_all[dataset.path] = []
            positions_relevant[dataset.path] = []
            for directory, identifier, position in get_all_positions(
                    dataset.path, args.num_workers):
                identifiers_all[dataset.path].append((directory, identifier))
                positions_all[dataset.path].append(position)
                if identifier in identifiers_relevant[dataset.path]:
                    positions_relevant[dataset.path].append(position)

        for dataset in args.datasets:
            LOGGER.info(
                "%d / %d / %d relevant / judged / total identifiers in dataset %s",
                len(identifiers_relevant[dataset.path]), len(identifiers_judged[dataset.path]),
                len(identifiers_all[dataset.path]), dataset.path.name)

        LOGGER.info("Pickling %s", args.positions.name)
        with gzip.open(args.positions.open("wb"), "wb") as f:
            pickle.dump({
                dataset.path: {
                    identifier: position for position, (_, identifier)
                    in zip(positions_all[dataset.path], identifiers_all[dataset.path])
                } for dataset in args.datasets}, f)

        LOGGER.info("Fitting density, and probability estimators")
        estimators = get_estimators(positions_all, positions_relevant)

        LOGGER.info("Computing density, and probability estimates")
        estimates = get_estimates(estimators, SAMPLES, args.num_workers)

        LOGGER.info("Pickling %s", args.estimates.name)
        with gzip.open(args.estimates.open("wb"), "wb") as f:
            pickle.dump(estimates, f)
    else:
        LOGGER.info("Unpickling %s", args.estimates.name)
        with gzip.open(args.estimates.open("rb"), "rb") as f:
            estimates = pickle.load(f)
    if args.plots:
        figure = plot_estimates(SAMPLES, estimates)
        for plot_path in args.plots:
            LOGGER.info("Plotting %s", plot_path.name)
            figure.savefig(str(plot_path))
1129495
def open(self):
        '''
        
        '''
        self._connection = sqlite3.connect(self._dbname)
        self._cursor = self._connection.cursor()
        self._session_info = SessionInfoTable(self._connection, self._cursor)
        self._reports = ReportsTable(self._connection, self._cursor)