本文整理汇总了Python中numexpr.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python numexpr.__version__方法的具体用法?Python numexpr.__version__怎么用?Python numexpr.__version__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numexpr
的用法示例。
在下文中一共展示了numexpr.__version__方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_numexpr_version
# 需要导入模块: import numexpr [as 别名]
# 或者: from numexpr import __version__ [as 别名]
def test_invalid_numexpr_version(engine, parser):
def testit():
a, b = 1, 2 # noqa
res = pd.eval('a + b', engine=engine, parser=parser)
assert res == 3
if engine == 'numexpr':
try:
import numexpr as ne
except ImportError:
pytest.skip("no numexpr")
else:
if (LooseVersion(ne.__version__) <
LooseVersion(_MIN_NUMEXPR_VERSION)):
with pytest.raises(ImportError):
testit()
else:
testit()
else:
testit()
示例2: check_invalid_numexpr_version
# 需要导入模块: import numexpr [as 别名]
# 或者: from numexpr import __version__ [as 别名]
def check_invalid_numexpr_version(engine, parser):
def testit():
a, b = 1, 2
res = pd.eval('a + b', engine=engine, parser=parser)
tm.assert_equal(res, 3)
if engine == 'numexpr':
try:
import numexpr as ne
except ImportError:
raise nose.SkipTest("no numexpr")
else:
if ne.__version__ < LooseVersion('2.0'):
with tm.assertRaisesRegexp(ImportError, "'numexpr' version is "
".+, must be >= 2.0"):
testit()
else:
testit()
else:
testit()
示例3: skip_if_no_ne
# 需要导入模块: import numexpr [as 别名]
# 或者: from numexpr import __version__ [as 别名]
def skip_if_no_ne(engine='numexpr'):
import nose
_USE_NUMEXPR = pd.computation.expressions._USE_NUMEXPR
if engine == 'numexpr':
try:
import numexpr as ne
except ImportError:
raise nose.SkipTest("numexpr not installed")
if not _USE_NUMEXPR:
raise nose.SkipTest("numexpr disabled")
if ne.__version__ < LooseVersion('2.0'):
raise nose.SkipTest("numexpr version too low: "
"%s" % ne.__version__)
示例4: test_invalid_numexpr_version
# 需要导入模块: import numexpr [as 别名]
# 或者: from numexpr import __version__ [as 别名]
def test_invalid_numexpr_version(engine, parser):
def testit():
a, b = 1, 2 # noqa
res = pd.eval('a + b', engine=engine, parser=parser)
assert res == 3
if engine == 'numexpr':
try:
import numexpr as ne
except ImportError:
pytest.skip("no numexpr")
else:
if ne.__version__ < LooseVersion(_MIN_NUMEXPR_VERSION):
with pytest.raises(ImportError):
testit()
else:
testit()
else:
testit()
示例5: test_compat
# 需要导入模块: import numexpr [as 别名]
# 或者: from numexpr import __version__ [as 别名]
def test_compat():
# test we have compat with our version of nu
from pandas.core.computation.check import _NUMEXPR_INSTALLED
try:
import numexpr as ne
ver = ne.__version__
if LooseVersion(ver) < LooseVersion(_MIN_NUMEXPR_VERSION):
assert not _NUMEXPR_INSTALLED
else:
assert _NUMEXPR_INSTALLED
except ImportError:
pytest.skip("not testing numexpr version compat")
示例6: _check_engine
# 需要导入模块: import numexpr [as 别名]
# 或者: from numexpr import __version__ [as 别名]
def _check_engine(engine):
"""Make sure a valid engine is passed.
Parameters
----------
engine : str
Raises
------
KeyError
* If an invalid engine is passed
ImportError
* If numexpr was requested but doesn't exist
"""
if engine not in _engines:
raise KeyError('Invalid engine {0!r} passed, valid engines are'
' {1}'.format(engine, list(_engines.keys())))
# TODO: validate this in a more general way (thinking of future engines
# that won't necessarily be import-able)
# Could potentially be done on engine instantiation
if engine == 'numexpr':
try:
import numexpr
except ImportError:
raise ImportError("'numexpr' not found. Cannot use "
"engine='numexpr' for query/eval "
"if 'numexpr' is not installed")
else:
ne_version = numexpr.__version__
if ne_version < LooseVersion('2.0'):
raise ImportError("'numexpr' version is %s, "
"must be >= 2.0" % ne_version)
示例7: test_compat
# 需要导入模块: import numexpr [as 别名]
# 或者: from numexpr import __version__ [as 别名]
def test_compat():
# test we have compat with our version of nu
from pandas.core.computation.check import _NUMEXPR_INSTALLED
try:
import numexpr as ne
ver = ne.__version__
if ver < LooseVersion(_MIN_NUMEXPR_VERSION):
assert not _NUMEXPR_INSTALLED
else:
assert _NUMEXPR_INSTALLED
except ImportError:
pytest.skip("not testing numexpr version compat")
示例8: package_check
# 需要导入模块: import numexpr [as 别名]
# 或者: from numexpr import __version__ [as 别名]
def package_check(pkg_name, version=None, app='pandas', checker=LooseVersion,
exc_failed_import=ImportError,
exc_failed_check=RuntimeError):
"""Check that the minimal version of the required package is installed.
Parameters
----------
pkg_name : string
Name of the required package.
version : string, optional
Minimal version number for required package.
app : string, optional
Application that is performing the check. For instance, the
name of the tutorial being executed that depends on specific
packages.
checker : object, optional
The class that will perform the version checking. Default is
distutils.version.LooseVersion.
exc_failed_import : Exception, optional
Class of the exception to be thrown if import failed.
exc_failed_check : Exception, optional
Class of the exception to be thrown if version check failed.
Examples
--------
package_check('numpy', '1.3')
package_check('networkx', '1.0', 'tutorial1')
"""
if app:
msg = '%s requires %s' % (app, pkg_name)
else:
msg = 'module requires %s' % pkg_name
if version:
msg += ' with version >= %s' % (version,)
try:
mod = __import__(pkg_name)
except ImportError:
raise exc_failed_import(msg)
if not version:
return
try:
have_version = mod.__version__
except AttributeError:
raise exc_failed_check('Cannot find version for %s' % pkg_name)
if checker(have_version) < checker(version):
raise exc_failed_check(msg)