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


Python compat.npy_load_module方法代码示例

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


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

示例1: _get_configuration_from_setup_py

# 需要导入模块: from numpy import compat [as 别名]
# 或者: from numpy.compat import npy_load_module [as 别名]
def _get_configuration_from_setup_py(self, setup_py,
                                         subpackage_name,
                                         subpackage_path,
                                         parent_name,
                                         caller_level = 1):
        # In case setup_py imports local modules:
        sys.path.insert(0, os.path.dirname(setup_py))
        try:
            setup_name = os.path.splitext(os.path.basename(setup_py))[0]
            n = dot_join(self.name, subpackage_name, setup_name)
            setup_module = npy_load_module('_'.join(n.split('.')),
                                           setup_py,
                                           ('.py', 'U', 1))
            if not hasattr(setup_module, 'configuration'):
                if not self.options['assume_default_configuration']:
                    self.warn('Assuming default configuration '\
                              '(%s does not define configuration())'\
                              % (setup_module))
                config = Configuration(subpackage_name, parent_name,
                                       self.top_path, subpackage_path,
                                       caller_level = caller_level + 1)
            else:
                pn = dot_join(*([parent_name] + subpackage_name.split('.')[:-1]))
                args = (pn,)
                def fix_args_py2(args):
                    if setup_module.configuration.__code__.co_argcount > 1:
                        args = args + (self.top_path,)
                    return args
                def fix_args_py3(args):
                    if setup_module.configuration.__code__.co_argcount > 1:
                        args = args + (self.top_path,)
                    return args
                if sys.version_info[0] < 3:
                    args = fix_args_py2(args)
                else:
                    args = fix_args_py3(args)
                config = setup_module.configuration(*args)
            if config.name!=dot_join(parent_name, subpackage_name):
                self.warn('Subpackage %r configuration returned as %r' % \
                          (dot_join(parent_name, subpackage_name), config.name))
        finally:
            del sys.path[0]
        return config 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:45,代码来源:misc_util.py

示例2: rundocs

# 需要导入模块: from numpy import compat [as 别名]
# 或者: from numpy.compat import npy_load_module [as 别名]
def rundocs(filename=None, raise_on_error=True):
    """
    Run doctests found in the given file.

    By default `rundocs` raises an AssertionError on failure.

    Parameters
    ----------
    filename : str
        The path to the file for which the doctests are run.
    raise_on_error : bool
        Whether to raise an AssertionError when a doctest fails. Default is
        True.

    Notes
    -----
    The doctests can be run by the user/developer by adding the ``doctests``
    argument to the ``test()`` call. For example, to run all tests (including
    doctests) for `numpy.lib`:

    >>> np.lib.test(doctests=True)  # doctest: +SKIP
    """
    from numpy.compat import npy_load_module
    import doctest
    if filename is None:
        f = sys._getframe(1)
        filename = f.f_globals['__file__']
    name = os.path.splitext(os.path.basename(filename))[0]
    m = npy_load_module(name, filename)

    tests = doctest.DocTestFinder().find(m)
    runner = doctest.DocTestRunner(verbose=False)

    msg = []
    if raise_on_error:
        out = lambda s: msg.append(s)
    else:
        out = None

    for test in tests:
        runner.run(test, out=out)

    if runner.failures > 0 and raise_on_error:
        raise AssertionError("Some doctests failed:\n%s" % "\n".join(msg)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:46,代码来源:utils.py

示例3: _init_info_modules

# 需要导入模块: from numpy import compat [as 别名]
# 或者: from numpy.compat import npy_load_module [as 别名]
def _init_info_modules(self, packages=None):
        """Initialize info_modules = {<package_name>: <package info.py module>}.
        """
        from numpy.compat import npy_load_module
        info_files = []
        info_modules = self.info_modules

        if packages is None:
            for path in self.parent_path:
                info_files.extend(self._get_info_files('*', path))
        else:
            for package_name in packages:
                package_dir = os.path.join(*package_name.split('.'))
                for path in self.parent_path:
                    names_files = self._get_info_files(package_dir, path)
                    if names_files:
                        info_files.extend(names_files)
                        break
                else:
                    try:
                        exec('import %s.info as info' % (package_name))
                        info_modules[package_name] = info
                    except ImportError as msg:
                        self.warn('No scipy-style subpackage %r found in %s. '\
                                  'Ignoring: %s'\
                                  % (package_name, ':'.join(self.parent_path), msg))

        for package_name, info_file in info_files:
            if package_name in info_modules:
                continue
            fullname = self.parent_name +'.'+ package_name
            if info_file[-1]=='c':
                filedescriptor = ('.pyc', 'rb', 2)
            else:
                filedescriptor = ('.py', 'U', 1)

            try:
                info_module = npy_load_module(fullname + '.info',
                                              info_file,
                                              filedescriptor)
            except Exception as msg:
                self.error(msg)
                info_module = None

            if info_module is None or getattr(info_module, 'ignore', False):
                info_modules.pop(package_name, None)
            else:
                self._init_info_modules(getattr(info_module, 'depends', []))
                info_modules[package_name] = info_module

        return 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:53,代码来源:_import_tools.py

示例4: rundocs

# 需要导入模块: from numpy import compat [as 别名]
# 或者: from numpy.compat import npy_load_module [as 别名]
def rundocs(filename=None, raise_on_error=True):
    """
    Run doctests found in the given file.

    By default `rundocs` raises an AssertionError on failure.

    Parameters
    ----------
    filename : str
        The path to the file for which the doctests are run.
    raise_on_error : bool
        Whether to raise an AssertionError when a doctest fails. Default is
        True.

    Notes
    -----
    The doctests can be run by the user/developer by adding the ``doctests``
    argument to the ``test()`` call. For example, to run all tests (including
    doctests) for `numpy.lib`:

    >>> np.lib.test(doctests=True) #doctest: +SKIP
    """
    from numpy.compat import npy_load_module
    import doctest
    if filename is None:
        f = sys._getframe(1)
        filename = f.f_globals['__file__']
    name = os.path.splitext(os.path.basename(filename))[0]
    m = npy_load_module(name, filename)

    tests = doctest.DocTestFinder().find(m)
    runner = doctest.DocTestRunner(verbose=False)

    msg = []
    if raise_on_error:
        out = lambda s: msg.append(s)
    else:
        out = None

    for test in tests:
        runner.run(test, out=out)

    if runner.failures > 0 and raise_on_error:
        raise AssertionError("Some doctests failed:\n%s" % "\n".join(msg)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:46,代码来源:utils.py


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