當前位置: 首頁>>代碼示例>>Python>>正文


Python tables.NoSuchNodeError方法代碼示例

本文整理匯總了Python中tables.NoSuchNodeError方法的典型用法代碼示例。如果您正苦於以下問題:Python tables.NoSuchNodeError方法的具體用法?Python tables.NoSuchNodeError怎麽用?Python tables.NoSuchNodeError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tables的用法示例。


在下文中一共展示了tables.NoSuchNodeError方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_data

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NoSuchNodeError [as 別名]
def load_data(self, where, name, dest_name=None, ich=None,
                  allow_missing=False, ondisk=False):
        try:
            node = self.h5file.get_node(where, name)
        except tables.NoSuchNodeError:
            if allow_missing:
                node_value = np.array([])
            else:
                self.h5file.close()
                raise IOError("Invalid file format: '%s' is missing." % name)
        else:
            node_value = node if ondisk else node.read()

        if dest_name is None:
            dest_name = hdf5_data_map.get(name, name)

        if ich is None:
            self.data.add(**{dest_name: node_value})
        else:
            if dest_name not in self.data:
                self.data.add(**{dest_name: [node_value]})
            else:
                self.data[dest_name].append(node_value) 
開發者ID:tritemio,項目名稱:FRETBursts,代碼行數:25,代碼來源:loader_legacy.py

示例2: _load_alex_periods_donor_acceptor

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NoSuchNodeError [as 別名]
def _load_alex_periods_donor_acceptor(data, meas_specs):
    # Both us- and ns-ALEX
    try:
        # Try to load alex period definitions
        D_ON = meas_specs.alex_excitation_period1.read()
        A_ON = meas_specs.alex_excitation_period2.read()
    except tables.NoSuchNodeError:
        # But if it fails it's OK, those fields are optional
        msg = """
        The current file lacks the alternation period defintion.
        You will need to manually add this info using:

          d.add(D_ON=D_ON, A_ON=A_ON)

        where `d` is a Data object and D_ON/A_ON is a tuple with start/stop
        values defining the D/A excitation excitation period. Values are in
        raw timestamps units.
        """
        log.warning(msg)
    else:
        data.add(D_ON=D_ON, A_ON=A_ON) 
開發者ID:tritemio,項目名稱:FRETBursts,代碼行數:23,代碼來源:loader.py

示例3: load_h5

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NoSuchNodeError [as 別名]
def load_h5(fname, genome='mm10'):
    try:
        import tables
    except ImportError:
        sys.stderr.write('Please install PyTables to read .h5 files: '
                         'https://www.pytables.org/usersguide/installation.html\n')
        exit(1)
    
    # Adapted from scanpy's read_10x_h5() method.
    with tables.open_file(str(fname), 'r') as f:
        try:
            dsets = {}
            for node in f.walk_nodes('/' + genome, 'Array'):
                dsets[node.name] = node.read()

            n_genes, n_cells = dsets['shape']
            data = dsets['data']
            if dsets['data'].dtype == np.dtype('int32'):
                data = dsets['data'].view('float32')
                data[:] = dsets['data']

            X = csr_matrix((data, dsets['indices'], dsets['indptr']),
                           shape=(n_cells, n_genes))
            genes = [ gene for gene in dsets['genes'].astype(str) ]
            assert(len(genes) == n_genes)
            assert(len(genes) == X.shape[1])
            
        except tables.NoSuchNodeError:
            raise Exception('Genome %s does not exist in this file.' % genome)
        except KeyError:
            raise Exception('File is missing one or more required datasets.')    

    return X, np.array(genes) 
開發者ID:brianhie,項目名稱:scanorama,代碼行數:35,代碼來源:process.py

示例4: load_h5

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NoSuchNodeError [as 別名]
def load_h5(fname, genome='mm10'):
    # Adapted from scanpy's read_10x_h5() method.
    with tables.open_file(str(fname), 'r') as f:
        try:
            dsets = {}
            for node in f.walk_nodes('/' + genome, 'Array'):
                dsets[node.name] = node.read()

            n_genes, n_cells = dsets['shape']
            data = dsets['data']
            
            if dsets['data'].dtype == np.dtype('int32'):
                data = dsets['data'].view('float32')
                data[:] = dsets['data']

            X = csr_matrix((data, dsets['indices'], dsets['indptr']),
                           shape=(n_cells, n_genes))
            genes = [ gene for gene in dsets['gene_names'].astype(str) ]
            assert(len(genes) == n_genes)
            assert(len(genes) == X.shape[1])
            
        except tables.NoSuchNodeError:
            raise Exception('Genome %s does not exist in this file.' % genome)
        except KeyError:
            raise Exception('File is missing one or more required datasets.')    

    return X, np.array(genes) 
開發者ID:brianhie,項目名稱:geosketch,代碼行數:29,代碼來源:process.py

示例5: remove_child

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NoSuchNodeError [as 別名]
def remove_child(self):
        """
        internal function to remove command that removes also child jobs.
        Do never use this command, since it will destroy the integrity of your project.
        """
        if "server" in self.project_hdf5.list_nodes():
            server_hdf_dict = self.project_hdf5["server"]
            if (
                "qid" in server_hdf_dict.keys()
                and str(self.status) in ["submitted", "running", "collect"]
                and server_hdf_dict["qid"] is not None
            ):
                self.project._queue_delete_job(server_hdf_dict["qid"])
        with self.project_hdf5.open("..") as hdf_parent:
            try:
                del hdf_parent[self.job_name]
                shutil.rmtree(str(self.working_directory))
            except (NoSuchNodeError, KeyError, OSError):
                print(
                    "This group does not exist in the HDF5 file {}".format(
                        self.job_name
                    )
                )
        if self.project_hdf5.is_empty:
            if os.path.isfile(self.project_hdf5.file_name):
                os.remove(self.project_hdf5.file_name)
                dir_name = self.project_hdf5.file_name.split(".h5")[0] + "_hdf5"
                if os.path.isdir(dir_name):
                    os.rmdir(dir_name)
        if self.job_id:
            self.project.db.delete_item(self.job_id) 
開發者ID:pyiron,項目名稱:pyiron,代碼行數:33,代碼來源:core.py

示例6: _add_usALEX_specs

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NoSuchNodeError [as 別名]
def _add_usALEX_specs(data, meas_specs):
    try:
        offset = meas_specs.alex_offset.read()
    except tables.NoSuchNodeError:
        log.warning('    No offset found, assuming offset = 0.')
        offset = 0
    data.add(offset=offset)
    data.add(alex_period=meas_specs.alex_period.read())
    _load_alex_periods_donor_acceptor(data, meas_specs) 
開發者ID:tritemio,項目名稱:FRETBursts,代碼行數:11,代碼來源:loader.py

示例7: load

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NoSuchNodeError [as 別名]
def load(cls, archive_name):
        """load a ReadArray from an hdf5 archive, note that ma_pos and ma_genes are
        discarded.

        :param str archive_name: name of a .h5 archive containing a saved ReadArray object
        :return ReadArray:
        """

        f = tb.open_file(archive_name, mode='r')
        data = f.root.data.read()

        try:
            f.get_node('/genes')
            genes = f.root.genes.read()
            positions = f.root.positions.read()
        except tb.NoSuchNodeError:
            indptr = f.root.indptr.read()
            indices = f.root.indices.read()
            genes = f.root.gene_data.read()
            positions = f.root.positions_data.read()
            genes = csr_matrix((genes, indices, indptr))
            positions = csr_matrix((positions, indices, indptr))

        return cls(data, genes, positions)

    # todo document me 
開發者ID:ambrosejcarr,項目名稱:seqc,代碼行數:28,代碼來源:read_array.py


注:本文中的tables.NoSuchNodeError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。