当前位置: 首页>>代码示例>>Python>>正文


Python dill.settings方法代码示例

本文整理汇总了Python中dill.settings方法的典型用法代码示例。如果您正苦于以下问题:Python dill.settings方法的具体用法?Python dill.settings怎么用?Python dill.settings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dill的用法示例。


在下文中一共展示了dill.settings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: session_load

# 需要导入模块: import dill [as 别名]
# 或者: from dill import settings [as 别名]
def session_load(self, hash, fname_session):
        """
        Load ipython session from file
        :param hash: cell hash
        :param fname_session: pathname to dumped session
        :return:
        """

        logging.debug('Cell {}: loading session from {}'.format(hash, fname_session))

        # 'dill.settings["recurse"] = True',
        # 'dill.settings["byref"] = True',

        inject_code = ['import dill',
                       'dill.load_session(filename="{}")'.format(fname_session),
                       ]

        inject_cell = nbf.v4.new_code_cell('\n'.join(inject_code))
        super().run_cell(inject_cell) 
开发者ID:elehcimd,项目名称:pynb,代码行数:21,代码来源:notebook.py

示例2: get_map_method

# 需要导入模块: import dill [as 别名]
# 或者: from dill import settings [as 别名]
def get_map_method(num_cpus):
    """
    Selects the correct `.map` method depending on the specified number of desired cores. If num_cpus>1, the
    multiprocessing/pathos pool is started here.

    Parameters
    ----------
    num_cpus: int

    Returns
    -------
    function
        `.map` method to be used by caller
    """
    if num_cpus == 1:
        return map

    # num_cpus > 1 -----------------

    # windows may require special treatment
    # if sys.platform == 'win32' and settings.POOL is None:
    #     warnings.warn("Windows users may explicitly need to  provide scqubits.settings.POOL.")

    # user is asking for more than 1 cpu; start pool from here
    if settings.MULTIPROC == 'pathos':
        try:
            import pathos
            import dill
        except ImportError:
            raise ImportError("scqubits multiprocessing mode set to 'pathos'. Need but cannot find 'pathos'/'dill'!")
        else:
            dill.settings['recurse'] = True
            settings.POOL = pathos.pools.ProcessPool(nodes=num_cpus)
            return settings.POOL.map
    if settings.MULTIPROC == 'multiprocessing':
        import multiprocessing
        settings.POOL = multiprocessing.Pool(processes=num_cpus)
        return settings.POOL.map
    else:
        raise ValueError("Unknown multiprocessing type: settings.MULTIPROC = {}".format(settings.MULTIPROC)) 
开发者ID:scqubits,项目名称:scqubits,代码行数:42,代码来源:cpu_switch.py

示例3: testPickle

# 需要导入模块: import dill [as 别名]
# 或者: from dill import settings [as 别名]
def testPickle(self):
        import dill
        dill.settings['recurse'] = False
        out1 = dill.dumps(self.mModel);
        lModel2 = dill.loads(out1);
        out2 = dill.dumps(lModel2);
        print(sorted(self.mModel.__dict__))
        print(sorted(lModel2.__dict__))
        for (k , v) in self.mModel.__dict__.items():
            print(k , self.mModel.__dict__[k])
            print(k , lModel2.__dict__[k])
        assert(out1 == out2)
        print("TEST_PICKLE_OK") 
开发者ID:antoinecarme,项目名称:pyaf,代码行数:15,代码来源:Keras_Models.py

示例4: __init__

# 需要导入模块: import dill [as 别名]
# 或者: from dill import settings [as 别名]
def __init__(
        self,
        filepath,
        chromsizes,
        bins,
        map=map,
        n_chunks=1,
        is_one_based=False,
        **kwargs
    ):
        try:
            import pysam
        except ImportError:
            raise ImportError("pysam is required to read tabix files")

        import dill
        import pickle

        dill.settings["protocol"] = pickle.HIGHEST_PROTOCOL

        self._map = map
        self.n_chunks = n_chunks
        self.is_one_based = bool(is_one_based)
        self.C2 = kwargs.pop("C2", 3)
        self.P2 = kwargs.pop("P2", 4)

        # all requested contigs will be placed in the output matrix
        self.gs = GenomeSegmentation(chromsizes, bins)

        # find available contigs in the contact list
        self.filepath = filepath
        self.n_records = None
        with pysam.TabixFile(filepath, "r", encoding="ascii") as f:
            try:
                self.file_contigs = [c.decode("ascii") for c in f.contigs]
            except AttributeError:
                self.file_contigs = f.contigs
            if not len(self.file_contigs):
                raise RuntimeError("No reference sequences found.")

        # warn about requested contigs not seen in the contact list
        for chrom in self.gs.contigs:
            if chrom not in self.file_contigs:
                warnings.warn(
                    "Did not find contig " + " '{}' in contact list file.".format(chrom)
                )

        warnings.warn(
            "NOTE: When using the Tabix aggregator, make sure the order of "
            "chromosomes in the provided chromsizes agrees with the chromosome "
            "ordering of read ends in the contact list file."
        ) 
开发者ID:mirnylab,项目名称:cooler,代码行数:54,代码来源:_ingest.py


注:本文中的dill.settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。