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


Python numpy.__version__方法代码示例

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


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

示例1: load_library

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def load_library(libname):
# numpy 1.6 has bug in ctypeslib.load_library, see numpy/distutils/misc_util.py
    if '1.6' in numpy.__version__:
        if (sys.platform.startswith('linux') or
            sys.platform.startswith('gnukfreebsd')):
            so_ext = '.so'
        elif sys.platform.startswith('darwin'):
            so_ext = '.dylib'
        elif sys.platform.startswith('win'):
            so_ext = '.dll'
        else:
            raise OSError('Unknown platform')
        libname_so = libname + so_ext
        return ctypes.CDLL(os.path.join(os.path.dirname(__file__), libname_so))
    else:
        _loaderpath = os.path.dirname(__file__)
        return numpy.ctypeslib.load_library(libname, _loaderpath)

#Fixme, the standard resouce module gives wrong number when objects are released
#see http://fa.bianp.net/blog/2013/different-ways-to-get-memory-consumption-or-lessons-learned-from-memory_profiler/#fn:1
#or use slow functions as memory_profiler._get_memory did 
开发者ID:pyscf,项目名称:pyscf,代码行数:23,代码来源:misc.py

示例2: get_pkg_info

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def get_pkg_info(pkg_path):
    ''' Return dict describing the context of this package

    Parameters
    ----------
    pkg_path : str
       path containing __init__.py for package

    Returns
    -------
    context : dict
       with named parameters of interest
    '''
    src, hsh = pkg_commit_hash(pkg_path)
    import numpy
    return dict(
        pkg_path=pkg_path,
        commit_source=src,
        commit_hash=hsh,
        sys_version=sys.version,
        sys_executable=sys.executable,
        sys_platform=sys.platform,
        np_version=numpy.__version__) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:25,代码来源:pkg_info.py

示例3: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def __init__(self, env_fns):
        if np.__version__ == '1.16.0':
            warnings.warn("""
NumPy 1.16.0 can cause severe memory leak in chainerrl.envs.MultiprocessVectorEnv.
We recommend using other versions of NumPy.
See https://github.com/numpy/numpy/issues/12793 for details.
""")  # NOQA

        nenvs = len(env_fns)
        self.remotes, self.work_remotes = zip(*[Pipe() for _ in range(nenvs)])
        self.ps = \
            [Process(target=worker, args=(work_remote, env_fn))
             for (work_remote, env_fn) in zip(self.work_remotes, env_fns)]
        for p in self.ps:
            p.start()
        self.last_obs = [None] * self.num_envs
        self.remotes[0].send(('get_spaces', None))
        self.action_space, self.observation_space = self.remotes[0].recv()
        self.closed = False 
开发者ID:chainer,项目名称:chainerrl,代码行数:21,代码来源:multiprocess_vector_env.py

示例4: sanity_check_dependencies

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def sanity_check_dependencies():
    import numpy
    import requests
    import six

    if distutils.version.LooseVersion(numpy.__version__) < distutils.version.LooseVersion('1.10.4'):
        logger.warn("You have 'numpy' version %s installed, but 'gym' requires at least 1.10.4. HINT: upgrade via 'pip install -U numpy'.", numpy.__version__)

    if distutils.version.LooseVersion(requests.__version__) < distutils.version.LooseVersion('2.0'):
        logger.warn("You have 'requests' version %s installed, but 'gym' requires at least 2.0. HINT: upgrade via 'pip install -U requests'.", requests.__version__)

# We automatically configure a logger with a simple stderr handler. If
# you'd rather customize logging yourself, run undo_logger_setup.
#
# (Note: this needs to happen before importing the rest of gym, since
# we may print a warning at load time.) 
开发者ID:ppaquette,项目名称:gym-pull,代码行数:18,代码来源:__init__.py

示例5: get_numpy_status

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def get_numpy_status():
    """
    Returns a dictionary containing a boolean specifying whether NumPy
    is up-to-date, along with the version string (empty string if
    not installed).
    """
    numpy_status = {}
    try:
        import numpy
        numpy_version = numpy.__version__
        numpy_status['up_to_date'] = parse_version(
            numpy_version) >= parse_version(NUMPY_MIN_VERSION)
        numpy_status['version'] = numpy_version
    except ImportError:
        traceback.print_exc()
        numpy_status['up_to_date'] = False
        numpy_status['version'] = ""
    return numpy_status 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:20,代码来源:setup.py

示例6: get_cython_status

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def get_cython_status():
    """
    Returns a dictionary containing a boolean specifying whether Cython is
    up-to-date, along with the version string (empty string if not installed).
    """
    cython_status = {}
    try:
        import Cython
        from Cython.Build import cythonize
        cython_version = Cython.__version__
        cython_status['up_to_date'] = parse_version(
            cython_version) >= parse_version(CYTHON_MIN_VERSION)
        cython_status['version'] = cython_version
    except ImportError:
        traceback.print_exc()
        cython_status['up_to_date'] = False
        cython_status['version'] = ""
    return cython_status 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:20,代码来源:setup.py

示例7: _show_system_info

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def _show_system_info(self):
        nose = import_nose()

        import numpy
        print("NumPy version %s" % numpy.__version__)
        relaxed_strides = numpy.ones((10, 1), order="C").flags.f_contiguous
        print("NumPy relaxed strides checking option:", relaxed_strides)
        npdir = os.path.dirname(numpy.__file__)
        print("NumPy is installed in %s" % npdir)

        if 'scipy' in self.package_name:
            import scipy
            print("SciPy version %s" % scipy.__version__)
            spdir = os.path.dirname(scipy.__file__)
            print("SciPy is installed in %s" % spdir)

        pyversion = sys.version.replace('\n', '')
        print("Python version %s" % pyversion)
        print("nose version %d.%d.%d" % nose.__versioninfo__) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:nosetester.py

示例8: status

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def status(self, status, **kwargs):
        if self.server:
            try:
                conn = HTTPConnection(self.server, self.port)
                conn.request('GET', '/version/')
                resp = conn.getresponse()

                if not resp.read().startswith('Experiment'):
                    raise RuntimeError()

                HTTPConnection(self.server, self.port).request('POST', '', str(dict({
                    'id': self.id,
                    'version': __version__,
                    'status': status,
                    'hostname': self.hostname,
                    'cwd': self.cwd,
                    'script_path': self.script_path,
                    'script': self.script,
                    'comment': self.comment,
                    'time': self.time,
                }, **kwargs)))
            except:
                warn('Unable to connect to \'{0}:{1}\'.'.format(self.server, self.port)) 
开发者ID:lucastheis,项目名称:c2s,代码行数:25,代码来源:experiment.py

示例9: find_class

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def find_class(self, module, name):
        """
        Helps Unpickler to find certain Numpy modules.
        """

        try:
            numpy_version = StrictVersion(numpy.__version__)

            if numpy_version >= StrictVersion('1.5.0'):
                if module == 'numpy.core.defmatrix':
                    module = 'numpy.matrixlib.defmatrix'

        except ValueError:
            pass

        return Unpickler.find_class(self, module, name) 
开发者ID:lucastheis,项目名称:c2s,代码行数:18,代码来源:experiment.py

示例10: exact_xp_2_xxstg_mad

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def exact_xp_2_xxstg_mad(xp, gamref):
    # to mad format
    N = xp.shape[0]
    xxstg = np.zeros((N, 6))
    pref = m_e_eV * np.sqrt(gamref ** 2 - 1)
    u = np.c_[xp[:, 3], xp[:, 4], xp[:, 5] + pref]
    gamma = np.sqrt(1 + np.sum(u * u, 1) / m_e_eV ** 2)
    beta = np.sqrt(1 - gamma ** -2)
    betaref = np.sqrt(1 - gamref ** -2)
    if np.__version__ > "1.8":
        p0 = np.linalg.norm(u, 2, 1).reshape((N, 1))
    else:
        p0 = np.sqrt(u[:, 0] ** 2 + u[:, 1] ** 2 + u[:, 2] ** 2).reshape((N, 1))
    u = u / p0
    cdt = -xp[:, 2] / (beta * u[:, 2])
    xxstg[:, 0] = xp[:, 0] + beta * u[:, 0] * cdt
    xxstg[:, 2] = xp[:, 1] + beta * u[:, 1] * cdt
    xxstg[:, 4] = cdt
    xxstg[:, 1] = xp[:, 3] / pref
    xxstg[:, 3] = xp[:, 4] / pref
    xxstg[:, 5] = (gamma / gamref - 1) / betaref
    return xxstg 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:24,代码来源:astra2ocelot.py

示例11: exact_xxstg_2_xp_mad

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def exact_xxstg_2_xp_mad(xxstg, gamref):
    # from mad format
    N = int(xxstg.size / 6)
    xp = np.zeros((N, 6))
    pref = m_e_eV * np.sqrt(gamref ** 2 - 1)
    betaref = np.sqrt(1 - gamref ** -2)
    gamma = (betaref * xxstg[5] + 1) * gamref
    beta = np.sqrt(1 - gamma ** -2)

    pz2pref = np.sqrt(((gamma * beta) / (gamref * betaref)) ** 2 - xxstg[1] ** 2 - xxstg[3] ** 2)

    u = np.c_[xxstg[1] / pz2pref, xxstg[3] / pz2pref, np.ones(N)]
    if np.__version__ > "1.8":
        norm = np.linalg.norm(u, 2, 1).reshape((N, 1))
    else:
        norm = np.sqrt(u[:, 0] ** 2 + u[:, 1] ** 2 + u[:, 2] ** 2).reshape((N, 1))
    u = u / norm
    xp[:, 0] = xxstg[0] - u[:, 0] * beta * xxstg[4]
    xp[:, 1] = xxstg[2] - u[:, 1] * beta * xxstg[4]
    xp[:, 2] = -u[:, 2] * beta * xxstg[4]
    xp[:, 3] = u[:, 0] * gamma * beta * m_e_eV
    xp[:, 4] = u[:, 1] * gamma * beta * m_e_eV
    xp[:, 5] = u[:, 2] * gamma * beta * m_e_eV - pref
    return xp 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:26,代码来源:astra2ocelot.py

示例12: exact_xp_2_xxstg_dp

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def exact_xp_2_xxstg_dp(xp, gamref):
    # dp/p0
    N = xp.shape[0]
    xxstg = np.zeros((N, 6))
    pref = m_e_eV * np.sqrt(gamref ** 2 - 1)
    u = np.c_[xp[:, 3], xp[:, 4], xp[:, 5] + pref]
    gamma = np.sqrt(1 + np.sum(u * u, 1) / m_e_eV ** 2)
    beta = np.sqrt(1 - gamma ** -2)
    if np.__version__ > "1.8":
        p0 = np.linalg.norm(u, 2, 1).reshape((N, 1))
    else:
        p0 = np.sqrt(u[:, 0] ** 2 + u[:, 1] ** 2 + u[:, 2] ** 2).reshape((N, 1))
    u = u / p0
    cdt = -xp[:, 2] / (beta * u[:, 2])
    xxstg[:, 0] = xp[:, 0] + beta * u[:, 0] * cdt
    xxstg[:, 2] = xp[:, 1] + beta * u[:, 1] * cdt
    xxstg[:, 4] = cdt
    xxstg[:, 1] = u[:, 0] / u[:, 2]
    xxstg[:, 3] = u[:, 1] / u[:, 2]
    xxstg[:, 5] = p0.reshape(N) / pref - 1
    return xxstg 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:23,代码来源:astra2ocelot.py

示例13: exact_xxstg_2_xp_dp

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def exact_xxstg_2_xp_dp(xxstg, gamref):
    # dp/p0
    N = len(xxstg) / 6
    xp = np.zeros((N, 6))
    pref = m_e_eV * np.sqrt(gamref ** 2 - 1)

    p = pref * (1 + xxstg[5::6])
    gamma = np.sqrt((p / m_e_eV) ** 2 + 1)

    beta = np.sqrt(1 - gamma ** -2)
    u = np.c_[xxstg[1::6], xxstg[3::6], np.ones(N)]
    if np.__version__ > "1.8":
        norm = np.linalg.norm(u, 2, 1).reshape((N, 1))
    else:
        norm = np.sqrt(u[:, 0] ** 2 + u[:, 1] ** 2 + u[:, 2] ** 2).reshape((N, 1))
    u = u / norm
    xp[:, 0] = xxstg[0::6] - u[:, 0] * beta * xxstg[4::6]
    xp[:, 1] = xxstg[2::6] - u[:, 1] * beta * xxstg[4::6]
    xp[:, 2] = -u[:, 2] * beta * xxstg[4::6]
    xp[:, 3] = u[:, 0] * gamma * beta * m_e_eV
    xp[:, 4] = u[:, 1] * gamma * beta * m_e_eV
    xp[:, 5] = u[:, 2] * gamma * beta * m_e_eV - pref
    return xp 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:25,代码来源:astra2ocelot.py

示例14: exact_xp_2_xxstg_de

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def exact_xp_2_xxstg_de(xp, gamref):
    # dE/E0
    N = xp.shape[0]
    xxstg = np.zeros((N, 6))
    pref = m_e_eV * np.sqrt(gamref ** 2 - 1)
    u = np.c_[xp[:, 3], xp[:, 4], xp[:, 5] + pref]
    gamma = np.sqrt(1 + np.sum(u * u, 1) / m_e_eV ** 2)
    beta = np.sqrt(1 - gamma ** -2)
    if np.__version__ > "1.8":
        p0 = np.linalg.norm(u, 2, 1).reshape((N, 1))
    else:
        p0 = np.sqrt(u[:, 0] ** 2 + u[:, 1] ** 2 + u[:, 2] ** 2).reshape((N, 1))
    u = u / p0
    cdt = -xp[:, 2] / (beta * u[:, 2])
    xxstg[:, 0] = xp[:, 0] + beta * u[:, 0] * cdt
    xxstg[:, 2] = xp[:, 1] + beta * u[:, 1] * cdt
    xxstg[:, 4] = cdt
    xxstg[:, 1] = u[:, 0] / u[:, 2]
    xxstg[:, 3] = u[:, 1] / u[:, 2]
    xxstg[:, 5] = gamma / gamref - 1
    return xxstg 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:23,代码来源:astra2ocelot.py

示例15: test_nan_to_nat_conversions

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __version__ [as 别名]
def test_nan_to_nat_conversions():

    df = DataFrame(dict({
        'A': np.asarray(
            lrange(10), dtype='float64'),
        'B': Timestamp('20010101')
    }))
    df.iloc[3:6, :] = np.nan
    result = df.loc[4, 'B'].value
    assert (result == tslib.iNaT)

    s = df['B'].copy()
    s._data = s._data.setitem(indexer=tuple([slice(8, 9)]), value=np.nan)
    assert (isna(s[8]))

    # numpy < 1.7.0 is wrong
    from distutils.version import LooseVersion
    if LooseVersion(np.__version__) >= LooseVersion('1.7.0'):
        assert (s[8].value == np.datetime64('NaT').astype(np.int64)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:21,代码来源:test_inference.py


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